summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-03 14:06:55 -0700
committerAndrew Godwin2022-12-03 14:07:30 -0700
commitb3df5e763c67c836554ccfb71b796ba1a0f51bfc (patch)
tree8859fcf5c4c720fda2efce68e48067b0aea4f6ec /core
parentc78e446d2f5fdb392f216febfaa81324142f891a (diff)
downloadtakahe-b3df5e763c67c836554ccfb71b796ba1a0f51bfc.tar.gz
takahe-b3df5e763c67c836554ccfb71b796ba1a0f51bfc.tar.bz2
takahe-b3df5e763c67c836554ccfb71b796ba1a0f51bfc.zip
Switch to secrets module for upload names
Diffstat (limited to 'core')
-rw-r--r--core/uploads.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/uploads.py b/core/uploads.py
index ef235f0..0160e2e 100644
--- a/core/uploads.py
+++ b/core/uploads.py
@@ -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}"