MalformedXML error when writing an empty file

Issue #220 new
Jamieson Warner
created an issue

Writing an empty string to a file gives an S3ResponseError.

from django.core.files.storage import default_storage
f = default_storage.open('---test', 'w')
f.write('')
f.close()
# S3ResponseError: 400 Bad Request

Here's what happens:

  1. There are no parts in the multipart request
  2. When it's time to send the multipart request to S3, multipart.py@to_xml spits out the xml string
<CompleteMultipartUpload>
</CompleteMultipartUpload>

which S3 doesn't like. If you write an empty string to a file and then close it, it should just blank the file.

Comments (0)

  1. Log in to comment