Created
March 5, 2012 22:57
-
-
Save jjmalina/1981810 to your computer and use it in GitHub Desktop.
storage.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.files.storage import get_storage_class | |
from storages.backends.s3boto import S3BotoStorage | |
class CachedS3BotoStorage(S3BotoStorage): | |
""" | |
S3 storage backend that saves the files locally, too. | |
""" | |
def __init__(self, *args, **kwargs): | |
super(CachedS3BotoStorage, self).__init__(*args, **kwargs) | |
self.local_storage = get_storage_class( | |
"compressor.storage.CompressorFileStorage")() | |
def save(self, name, content): | |
name = super(CachedS3BotoStorage, self).save(name, content) | |
self.local_storage._save(name, content) | |
return name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment