Set the correct content type for gzipped files with the .gz ext #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using the gzip plugin it's possible to specify a
keep
optionwhich will maintain both the original uncompressed file and save
the gzipped version with a
.gz
suffix. Amazon S3 does not detectcontent type or encoding so this is all managed in this plugin via
the mime package. The default mime type is
application/octet-stream
which is exactly what is detected for a
.gz
files. Uploading.js.gz
and.css.gz
files without their correct content typesblows up some browsers with syntax errors (e.g. Safari)
This PR makes the uploader a little smarter. If we detect a file is
gzipped and has a
.gz
extension we strip the extension and look forthe non-gzipped file in the file path list. If it's found, we'll do
a mime lookup for the non-gzipped file and use that content type
and encoding instead. If a non-gzipped counterpart isn't found we
will still upload the gzipped file as an
application/octet-stream
so this shouldn't break any valid gzip assets that aren't compressed
as part of the gzip plugin in the pipeline.