Start content

This commit is contained in:
2021-08-07 17:37:36 +02:00
parent a3f31608a8
commit ec0a8c98e7
1391 changed files with 13744 additions and 14 deletions

View File

@@ -0,0 +1,13 @@
import os
import uuid
from django.utils.deconstruct import deconstructible
# Ref: https://stackoverflow.com/questions/2673647/enforce-unique-upload-file-names-using-django
@deconstructible
class RandomFileName(object):
def __init__(self, path):
self.path = os.path.join(path, "%s%s")
def __call__(self, _, filename):
extension = os.path.splitext(filename)[1]
return self.path % (uuid.uuid4(), extension)