summaryrefslogtreecommitdiff
path: root/storages/backends/overwrite.py
diff options
context:
space:
mode:
authorYuval Adam <yuval@segmanta.com>2014-03-20 17:49:16 +0200
committerYuval Adam <yuval@segmanta.com>2014-03-20 17:49:16 +0200
commit75f93a3f7854a7383febd047391e2bfd4caceee0 (patch)
treed5e634ef292c6b84acacc3982dbcaa0d300a346e /storages/backends/overwrite.py
Initial git fork of django-storagesHEADmaster
Diffstat (limited to 'storages/backends/overwrite.py')
-rw-r--r--storages/backends/overwrite.py19
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