Fix a bug in s3 log uploader with .gz files

When trying to upload .gz files, we do not set the ContentEncoding
argument to upload_fileobj but leave it as None. The upload then fails
because NoneType is not allowed. Therefore, leave out this parameter,
and also the ContentType parameter, from the extra args completely if
they are not set.

Change-Id: I601944ac83d5e823aa4dcfd0db880a38474288af
This commit is contained in:
Benjamin Schanzel 2021-06-30 10:11:49 +02:00
parent 73481298e3
commit 1ab9ca3ed9

View File

@ -169,10 +169,11 @@ class Uploader():
content_encoding = file_detail.encoding
data = open(file_detail.full_path, 'rb')
extra_args = dict(
ContentType=file_detail.mimetype,
ContentEncoding=content_encoding
)
extra_args = {}
if file_detail.mimetype:
extra_args['ContentType'] = file_detail.mimetype
if content_encoding:
extra_args['ContentEncoding'] = content_encoding
if self.public:
extra_args['ACL'] = 'public-read'