diff options
| author | Yuval Adam <yuval@segmanta.com> | 2014-03-20 17:49:16 +0200 |
|---|---|---|
| committer | Yuval Adam <yuval@segmanta.com> | 2014-03-20 17:49:16 +0200 |
| commit | 75f93a3f7854a7383febd047391e2bfd4caceee0 (patch) | |
| tree | d5e634ef292c6b84acacc3982dbcaa0d300a346e /storages/backends/overwrite.py | |
Diffstat (limited to 'storages/backends/overwrite.py')
| -rw-r--r-- | storages/backends/overwrite.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/storages/backends/overwrite.py b/storages/backends/overwrite.py new file mode 100644 index 0000000..fba464a --- /dev/null +++ b/storages/backends/overwrite.py @@ -0,0 +1,19 @@ +from django.core.files.storage import FileSystemStorage + + +class OverwriteStorage(FileSystemStorage): + """ + Comes from http://www.djangosnippets.org/snippets/976/ + (even if it already exists in S3Storage for ages) + + See also Django #4339, which might add this functionality to core. + """ + + def get_available_name(self, name): + """ + Returns a filename that's free on the target storage system, and + available for new content to be written to. + """ + if self.exists(name): + self.delete(name) + return name |
