-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Description
In order to serve correctly S3 object from cloudfront origin, we need to set correctly S3 object mime-type.
Unfortunately the S3 client does not provide any mime-type when calling upload_file.
It could be possible to use at least the mimetypes module for the most common mime-types based on file extension in s3client.py:
def _upload_file(self, local_path: Union[str, os.PathLike], cloud_path: S3Path) -> S3Path:
obj = self.s3.Object(cloud_path.bucket, cloud_path.key)
extra_args = {}
content_type, content_encoding = mimetypes.guess_type(str(local_path))
if content_type is not None:
extra_args["ContentType"] = content_type
if content_encoding is not None:
extra_args["ContentEncoding"] = content_encoding
obj.upload_file(str(local_path), Config=self.boto3_transfer_config, ExtraArgs=extra_args)
return cloud_path
pjbull
Metadata
Metadata
Assignees
Labels
No labels