Skip to content

Commit 685b02d

Browse files
authored
Merge pull request #142 from etianen/fix-141
Fixing ManifestStaticS3Storage
2 parents 38f6fbf + 1c85484 commit 685b02d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

django_s3_storage/storage.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ class ManifestStaticS3Storage(ManifestFilesMixin, StaticS3Storage):
524524
"AWS_S3_MAX_AGE_SECONDS_CACHED": 60 * 60 * 24 * 365, # 1 year.
525525
})
526526

527+
def _save(self, name, content):
528+
# See: https://github.com/etianen/django-s3-storage/issues/141
529+
# Fix adapted from: https://github.com/jschneier/django-storages/pull/968
530+
content.seek(0)
531+
with self.new_temporary_file() as tmp:
532+
shutil.copyfileobj(content, tmp)
533+
return super()._save(name, File(tmp))
534+
527535
def post_process(self, *args, **kwargs):
528536
initial_aws_s3_max_age_seconds = self.settings.AWS_S3_MAX_AGE_SECONDS
529537
self.settings.AWS_S3_MAX_AGE_SECONDS = self.settings.AWS_S3_MAX_AGE_SECONDS_CACHED

0 commit comments

Comments
 (0)