jazzband / django-queued-storage

Provides a proxy for Django storage backends that allows you to upload files locally and eventually serve them remotely
http://django-queued-storage.rtfd.org/
BSD 3-Clause "New" or "Revised" License
317 stars 62 forks source link

Fixes for case where files are deleted locally after transfer. #12

Closed celiao closed 9 years ago

celiao commented 10 years ago

These changes cover the case where files are deleted locally after transfer, and you later want to upload a file with the same name. This is especially important for environments like Heroku where the local files are wiped out after pushing a new repository.

Specifically, save() calls self.get_available_name() before saving the file locally. get_available_name() checks both the local and remote storage systems (rather than only the local) to determine the available name.

For example, consider the case where a file named image.jpg exists on the remote storage but not on the local storage. You want to upload another file with the name image.jpg (with or without the same contents). With these changes, both the local and remote storage systems will be checked, and the file will be uploaded as image_1.jpg, as appropriate. https://docs.djangoproject.com/en/dev/howto/custom-file-storage/#django.core.files.storage.get_available_name