def _upload_to_s3(file):
extra_args = {"ContentType": "text/plain"}
+ text_html_extra_args = {"ContentType": "text/html", "ContentEncoding": mimetypes.guess_type(file)[1]}
text_plain_extra_args = {"ContentType": "text/plain", "ContentEncoding": mimetypes.guess_type(file)[1]}
app_xml_extra_args = {"ContentType": "application/xml'", "ContentEncoding": mimetypes.guess_type(file)[1]}
if file == "_tmpfile":
log.error(e)
return False
return True
+ elif mimetypes.guess_type(file)[0] in "text/html":
+ extra_args = text_html_extra_args
+ try:
+ s3.Bucket(s3_bucket).upload_file(file, "{}{}".format(s3_path, file), ExtraArgs=extra_args)
+ except ClientError as e:
+ log.error(e)
+ return False
+ return True
elif mimetypes.guess_type(file)[0] is None or mimetypes.guess_type(file)[0] in "text/plain":
extra_args = text_plain_extra_args
try:
--- /dev/null
+---
+fixes:
+ - |
+ Handle content-type for html uploaded files to S3 storage correctly.
+ This fixes the issue with detecting and setting ExtraArgs for html
+ to text/html instead of text/plain.