Last active
August 3, 2024 13:19
-
-
Save niccolomineo/2b034f97571ec8106ea41248b4e5156e to your computer and use it in GitHub Desktop.
A file system storage with file overwriting capabilities
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
"""Django storages.""" | |
from django.core.files.storage import FileSystemStorage | |
class FileSystemOverwriteStorage(FileSystemStorage): | |
"""A file system storage with file overwriting capabilities.""" | |
def get_available_name(self, name, max_length=None): | |
"""Return the available name.""" | |
self.delete(name) | |
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