terricain / aioboto3

Wrapper to use boto3 resources with the aiobotocore async backend
Apache License 2.0
732 stars 75 forks source link

s3.upload_file with zero byte length fails with MalformedXML error #229

Closed J-Rojas closed 3 years ago

J-Rojas commented 3 years ago

Description

I'm using aioboto3 to upload various files. Some files occasionally have zero byte length.

What I Did

await s3.upload_file(file_name, s3_bucket, object_name, 
      Callback=callback,
      ExtraArgs={ 
          'ACL': s3_acl,
          'Metadata': meta_data
      }
  )     

# The above fails when the file is zero length with the following error.

An error occurred (MalformedXML) when calling the CompleteMultipartUpload operation: Unknown

# Relevant Header sample (possibly missing ETag?)

'headers': {'User-Agent': 'Boto3/1.16.52 Python/3.8.5 Linux/5.11.0-7614-generic Botocore/1.19.52'}, 'body': b'<CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />'

What I expected

I had to work around this by using s3.put_object() with an empty byte array. It would be great if the zero byte length files worked through upload_file().

terricain commented 3 years ago

9.0.0 is out, can you try with that