##// END OF EJS Templates
Use UUID as a unique file name for uploads
neko259 -
r1767:56a71883 default
parent child Browse files
Show More
@@ -2,6 +2,8 b''
2 2 This module contains helper functions and helper classes.
3 3 """
4 4 import hashlib
5 import uuid
6
5 7 from boards.abstracts.constants import FILE_DIRECTORY
6 8 from random import random
7 9 import time
@@ -130,12 +132,8 b' def get_extension(filename):'
130 132
131 133
132 134 def get_upload_filename(model_instance, old_filename):
133 # TODO Use something other than random number in file name
134 135 extension = get_extension(old_filename)
135 new_name = '{}{}.{}'.format(
136 str(int(time.mktime(time.gmtime()))),
137 str(int(random() * 1000)),
138 extension)
136 new_name = '{}.{}'.format(uuid.uuid4(), extension)
139 137
140 138 return os.path.join(FILE_DIRECTORY, new_name)
141 139
General Comments 0
You need to be logged in to leave comments. Login now