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

fix(deployer): add content-encoding if mimetypes infers one #8498

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions deployer/src/deployer/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ def content_type(self):

return mime_type

@property
def content_encoding(self):
return mimetypes.guess_type(str(self.file_path))[1]

@property
def is_hashed(self):
return hashed_filename_regex.search(self.file_path.name)
Expand Down Expand Up @@ -218,15 +222,20 @@ def cache_control(self):

def upload(self, bucket_manager):
if not self.dry_run:
extra_args = {
"ACL": "public-read",
"ContentType": self.content_type,
"CacheControl": self.cache_control,
}
content_encoding = self.content_encoding
if content_encoding:
extra_args["ContentEncoding"] = content_encoding

bucket_manager.client.upload_file(
str(self.file_path),
bucket_manager.bucket_name,
self.key,
ExtraArgs={
"ACL": "public-read",
"ContentType": self.content_type,
"CacheControl": self.cache_control,
},
ExtraArgs=extra_args,
)


Expand Down