diff --git a/shimatta_kenkyusho/shimatta_modules/RandomFileName.py b/shimatta_kenkyusho/shimatta_modules/RandomFileName.py index 279fe27..d457715 100644 --- a/shimatta_kenkyusho/shimatta_modules/RandomFileName.py +++ b/shimatta_kenkyusho/shimatta_modules/RandomFileName.py @@ -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) \ No newline at end of file + 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)