mirror of
https://github.com/jointakahe/takahe.git
synced 2024-12-23 05:56:29 +00:00
Switch to secrets module for upload names
This commit is contained in:
parent
c78e446d2f
commit
b3df5e763c
1 changed files with 2 additions and 3 deletions
|
@ -1,6 +1,5 @@
|
|||
import base64
|
||||
import os
|
||||
import uuid
|
||||
import secrets
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
|
@ -11,5 +10,5 @@ def upload_namer(prefix, instance, filename):
|
|||
"""
|
||||
now = timezone.now()
|
||||
_, old_extension = os.path.splitext(filename)
|
||||
new_filename = base64.b32encode(uuid.uuid4().bytes).decode("ascii")
|
||||
new_filename = secrets.token_urlsafe(20)
|
||||
return f"{prefix}/{now.year}/{now.month}/{now.day}/{new_filename}{old_extension}"
|
||||
|
|
Loading…
Reference in a new issue