diff options
author | pmikus <pmikus@cisco.com> | 2021-09-16 12:28:34 +0000 |
---|---|---|
committer | pmikus <pmikus@cisco.com> | 2021-09-16 12:28:34 +0000 |
commit | 5ef729e9d92d1bcd35345cf27581d15e01962c7c (patch) | |
tree | a73fe373056bd8143e86431b3c238532d95c2c2f /jjb/scripts | |
parent | 03dc9f4a3fdbca12ac1f0893081ffea39a7e0792 (diff) |
FIX: Improve ContentEncoding handling
+ Each bucket has different settings that is accepted.
This patch helps to make all buckets and jobs works
as expected for their settings.
+ Tested on sandbox on all kind of jobs (tox,docs,trending)
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: Ibf7e81f06c9bd9b3f17194231cbd4f7e83596305
Diffstat (limited to 'jjb/scripts')
-rw-r--r-- | jjb/scripts/publish_library_py.sh | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/jjb/scripts/publish_library_py.sh b/jjb/scripts/publish_library_py.sh index f9b6a378c..a6e2edfaa 100644 --- a/jjb/scripts/publish_library_py.sh +++ b/jjb/scripts/publish_library_py.sh @@ -126,25 +126,22 @@ def upload(s3_resource, s3_bucket, src_fpath, s3_path): :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": @@ -156,6 +153,9 @@ def upload(s3_resource, s3_bucket, src_fpath, s3_path): 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 @@ -250,7 +250,7 @@ def deploy_s3(s3_bucket, s3_path, build_url, workspace): except KeyError: s3_resource = boto3.resource( u"s3" - ) + ) previous_dir = os.getcwd() work_dir = tempfile.mkdtemp(prefix="backup-s3.") |