Created
March 23, 2020 07:44
-
-
Save dorosch/d5f0b6ce58bbd74a93f16ec2c22654ba to your computer and use it in GitHub Desktop.
Implement django-storage with random uuid-path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import uuid | |
from django.core.files import storage as django_storage | |
class LocalMediaStorage(django_storage.FileSystemStorage): | |
def get_available_name(self, name, max_length=None): | |
path, filename = os.path.split(name) | |
name = os.path.join(path, str(uuid.uuid4()), filename) | |
return super().get_available_name(name, max_length) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment