1. Nivl
  2. django-storages

Commits

Jannis Leidel  committed e51055a

Close the Gzip file again and reset the file's current position to the beginning.

  • Participants
  • Parent commits 4c0e805
  • Branches default

Comments (0)

Files changed (1)

File storages/backends/s3boto.py

View file
  • Ignore whitespace
         """Gzip a given string content."""
         zbuf = StringIO()
         zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
-        zfile.write(content.read())
-        zfile.close()
+        try:
+            zfile.write(content.read())
+        finally:
+            zfile.close()
         content.file = zbuf
+        content.seek(0)
         return content
 
     def _open(self, name, mode='rb'):