log.error(e)
return False
return True
- elif mimetypes.guess_type(file)[0] in "text/html":
- extra_args = text_html_extra_args
+ elif mimetypes.guess_type(file)[0] is None or mimetypes.guess_type(file)[0] in "text/plain":
+ extra_args = text_plain_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
+ 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:
--- /dev/null
+---
+fixes:
+ - |
+ When checking mimetype during _upload_to_s3, the newly-added text/html type
+ was checking before it is checked for None, which is a potential TypeError.
+ By moving it after the variable is checked for None, the feature is safe
+ without requiring any further modifications.