:type src_fpath: str
:type s3_path: str
"""
+ mime = MimeTypes().guess_type(src_fpath)[0]
+ encoding = MimeTypes().guess_type(src_fpath)[1]
+
extra_args = {
u"ContentType": u"text/plain"
}
text_html_extra_args = {
- u"ContentType": u"text/html",
- u"ContentEncoding": MimeTypes().guess_type(src_fpath)[1]
+ u"ContentType": u"text/html"
}
text_plain_extra_args = {
- u"ContentType": u"text/plain",
- u"ContentEncoding": MimeTypes().guess_type(src_fpath)[1]
+ u"ContentType": u"text/plain"
}
app_xml_extra_args = {
- u"ContentType": u"application/xml",
- u"ContentEncoding": MimeTypes().guess_type(src_fpath)[1]
+ u"ContentType": u"application/xml"
}
- mime = MimeTypes().guess_type(src_fpath)[0]
- encoding = MimeTypes().guess_type(src_fpath)[1]
-
if mime is None and encoding is None:
extra_args = extra_args
elif mime is None or mime in u"text/plain":
else:
extra_args = extra_args
+ if encoding:
+ extra_args[u"ContentEncoding"] = encoding
+
try:
s3_resource.Bucket(s3_bucket).upload_file(
src_fpath, s3_path, ExtraArgs=extra_args
except KeyError:
s3_resource = boto3.resource(
u"s3"
- )
+ )
previous_dir = os.getcwd()
work_dir = tempfile.mkdtemp(prefix="backup-s3.")