1 from hashlib import sha1
2 from django.core.files.storage import FileSystemStorage
3 from django.core.files.uploadedfile import UploadedFile
6 class ExistingFile(UploadedFile):
8 def __init__(self, path, *args, **kwargs):
10 return super(ExistingFile, self).__init__(*args, **kwargs)
12 def temporary_file_path(self):
19 class OverwriteStorage(FileSystemStorage):
21 def _save(self, name, content):
24 return super(OverwriteStorage, self)._save(name, content)
26 def get_available_name(self, name):
32 for piece in iter(lambda: f.read(1024*1024), ''):
34 return sha.hexdigest()