Rework file upload structure to use subfolders for better file performance
This commit is contained in:
parent
873e13542a
commit
ba0da19810
@ -6,8 +6,13 @@ from django.utils.deconstruct import deconstructible
|
||||
@deconstructible
|
||||
class RandomFileName(object):
|
||||
def __init__(self, path):
|
||||
self.path = os.path.join(path, "%s%s")
|
||||
self.path = os.path.join(path, "%s/%s/%s%s")
|
||||
|
||||
def __call__(self, _, filename):
|
||||
extension = os.path.splitext(filename)[1]
|
||||
return self.path % (uuid.uuid4(), extension)
|
||||
file_uuid = uuid.uuid4()
|
||||
uuid_str = str(file_uuid)
|
||||
first_char = uuid_str[0]
|
||||
second_char = uuid_str[1]
|
||||
|
||||
return self.path % (first_char, second_char, file_uuid, extension)
|
||||
|
Loading…
Reference in New Issue
Block a user