Why am I getting 400 when uploading a file using boto?

I am trying to upload a file in boto ,

 import io from boto.s3 import connection from boto.s3 import key conn = connection.S3Connection() bucket = conn.get_bucket('my-bucket') my_key = key.Key(bucket, 'asdf') d = b'this is a test....\n' * 512000 f = io.BytesIO(d) my_key.send_file(f, size=4*1024) 

However, this leads to:

 boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request <?xml version="1.0" encoding="UTF-8"?><Error><Code>BadRequest</Code><Message>An error occurred when parsing the HTTP request.</Message><RequestId>[hex request ID]</RequestId><HostId>[giant piece of base64]</HostId></Error> 

Why does this query not work?

(note: the whole reason I use send_file is because open seems to support read only ...)

+6
source share
1 answer

What it costs, replacing send_file() with set_contents_from_file() , worked for me (I had the same error).

+4
source

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


All Articles