Upload 0 bytes of file to Amazon S3

Can I upload a file of 0 bytes in Amazon S3? My standard answer would be to not allow it, but I have a site that would like to allow users to upload empty .txt files, which are 0 bytes.

Amazon returns a formatted 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 am using boto == 2.3.0 with Flask == 0.8

0
source share
1 answer

Yes it is 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 it works for me. The error you get indicates that something else is wrong.

+3
source

Source: https://habr.com/ru/post/1486744/


All Articles