Created
January 18, 2017 19:26
-
-
Save andriisoldatenko/dec7f4e4fa2a54697e0afc65352f92c7 to your computer and use it in GitHub Desktop.
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.s3boto3 import S3Boto3Storage | |
class StaticS3Boto3Storage(S3Boto3Storage): | |
file_overwrite = True | |
class CachedS3BotoStorage(S3Boto3Storage): | |
""" | |
S3 storage backend that saves the files locally, too. | |
""" | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.local_storage = get_storage_class( | |
"django.core.files.storage.FileSystemStorage")() | |
def save(self, name, content, max_length=None): | |
name = self.local_storage._save(name, content) | |
super().save(name, content, max_length=max_length) | |
return name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment