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

The s3boto3 backend overrides custom Content-Encoding object parameters #391

Closed
aldencolerain opened this issue Sep 6, 2017 · 0 comments · Fixed by #828
Closed

The s3boto3 backend overrides custom Content-Encoding object parameters #391

aldencolerain opened this issue Sep 6, 2017 · 0 comments · Fixed by #828
Labels

Comments

@aldencolerain
Copy link

aldencolerain commented Sep 6, 2017

When a custom Content-Encoding is specified in the AWS_S3_OBJECT_PARAMETERS setting it is overwritten by the encoding calculated by mimetypes. It looks like this bug was introduced in PR #122.

_type, encoding = mimetypes.guess_type(name)

This could be easily fixed by only updating the Content-Encoding to the guessed encoding only if it wasn't already present in object parameters. See below:

if self.gzip and content_type in self.gzip_content_types:
content = self._compress_content(content)
parameters.update({'ContentEncoding': 'gzip'})
elif encoding:
# If the content already has a particular encoding, set it
parameters.update({'ContentEncoding': encoding})

This is an issue when you want to upload a gz file but you don't want the browser to automatically attempt to decompress it, you could work around with content-disposition but it would be better to be able to control Content-Encoding and not have it overridden by the guessed encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants