blob: fba464aae8ee40e5f94dccc49d187465989e66ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
|