0

Is it possible to upload a 0 byte file to Amazon S3? My standard response would be to not allow it, but I have a site that would like to allow users to upload blank .txt files, which happen to be 0 bytes.

Amazon returns a Malformed XML response:

<Error>
<Code>MalformedXML</Code>
<Message>The XML you provided was not well-formed or did not validate against our published schema</Message>
<RequestId>234...</RequestId>
<HostId>2309fsdijflsd...w32r09s</HostId>
</Error>

I'm using boto==2.3.0 with Flask==0.8

Liyan Chang
  • 7,721
  • 3
  • 39
  • 59

1 Answers1

3

Yes, it's possible.

>>> import boto
>>> c = boto.connect_s3()
>>> b = c.lookup('mybucket')
>>> k = b.new_key('empty')
>>> k.set_contents_from_string('')
>>> for k in b:
       print k.name, k.size
...
empty 0
...
>>>

At least that works for me. The error you are getting suggests something else is going wrong.

garnaat
  • 44,310
  • 7
  • 123
  • 103