Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing ManifestStaticS3Storage #142

Merged
merged 3 commits into from
Jul 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions django_s3_storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ class ManifestStaticS3Storage(ManifestFilesMixin, StaticS3Storage):
"AWS_S3_MAX_AGE_SECONDS_CACHED": 60 * 60 * 24 * 365, # 1 year.
})

def _save(self, name, content):
# See: https://github.com/etianen/django-s3-storage/issues/141
# Fix adapted from: https://github.com/jschneier/django-storages/pull/968
content.seek(0)
with self.new_temporary_file() as tmp:
shutil.copyfileobj(content, tmp)
return super()._save(name, File(tmp))

def post_process(self, *args, **kwargs):
initial_aws_s3_max_age_seconds = self.settings.AWS_S3_MAX_AGE_SECONDS
self.settings.AWS_S3_MAX_AGE_SECONDS = self.settings.AWS_S3_MAX_AGE_SECONDS_CACHED
Expand Down