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

adds logic to upload compressed files with right mime type and right content-encoding #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sprockow
Copy link
Contributor

@sprockow sprockow commented Nov 3, 2020

Background

##81

Proposed changes

If not specified within the objectHeaders option, uploaded objects are given a content-type header automatically based on their file extension using mime 's lookup function. Unfortunately, this causes problems if you attempt to upload a file with a file extension + a compression extension. ie main.123.js.gz .

Now, there aren't any standards (that I know of ) to reference here, but the common practice that I've seen is that gzip compressed files follow the pattern

*.{file-extension}.gz

and brotli compressed files follow this pattern:

*.{file-extension}.br

I haven't come across anything for other compression encoding types, but I would be happy to add support in this PR

If we assume that users who precompress their file will follow the above described practice, then this merging this PR will do the following:

  1. Files matching *.*.br will be given a Content-Encoding header value of br, in accordance with brotli standard
  2. Files ending with *.*.gz will be given a Content-Encoding header value of gzip in accordance with gzip standard
  3. Files that do not match either above pattern will be passed to the existing logic and given a mime type based on file extension

@sprockow
Copy link
Contributor Author

Updated README.md and fixed some merge conflicts.

@Shereef
Copy link
Collaborator

Shereef commented Feb 26, 2022

I would want to do some research to see if there are other encodings we can support like x-tar or x-tar-gz and also understand what deflate is

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding

please allow some times for me to brush up on those topics

@Shereef Shereef force-pushed the mime-types-with-content-encoding branch from d4b72f8 to 5a9e8c3 Compare February 28, 2022 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants