Skip to content

Commit

Permalink
Added an encoding check to the publish command that will add the gzip…
Browse files Browse the repository at this point in the history
… ContentEncoding header anytime the mimetypes guess its a gzipped file
  • Loading branch information
palewire committed Dec 29, 2017
1 parent dd3452f commit 6ba1e36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bakery/management/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,16 @@ def upload_to_s3(self, key, filename):
and upload the item to S3
"""
extra_args = {'ACL': self.acl}
# guess and add the mimetype to header
content_type = mimetypes.guess_type(filename)[0]
# determine the mimetype of the file
guess = mimetypes.guess_type(filename)
content_type = guess[0]
encoding = guess[1]

if content_type:
extra_args['ContentType'] = content_type

# add the gzip headers, if necessary
if self.gzip and content_type in self.gzip_content_types:
if (self.gzip and content_type in self.gzip_content_types) or encoding == 'gzip':
extra_args['ContentEncoding'] = 'gzip'

# add the cache-control headers if necessary
Expand Down
Binary file added example/date_views/static/dem-output.bin.gz
Binary file not shown.

0 comments on commit 6ba1e36

Please sign in to comment.