I'm attempting to upload a file to 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 results in:
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 is this request failing?
(note: the whole reason I'm using send_file
here is because open
apparently only supports reading…)
For what it's worth, replacing send_file()
with set_contents_from_file()
worked for me (I had the same error).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With