Skip to content

Commit

Permalink
Merge pull request #142 from etianen/fix-141
Browse files Browse the repository at this point in the history
Fixing ManifestStaticS3Storage
  • Loading branch information
etianen committed Jul 10, 2022
2 parents 38f6fbf + 1c85484 commit 685b02d
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 685b02d

Please sign in to comment.