为什么在使用boto上传文件时会得到400?

Tha*_*tos 6 python amazon-s3 boto amazon-web-services

我正在尝试上传文件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)
Run Code Online (Sandbox Code Playgroud)

但是,这导致:

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>
Run Code Online (Sandbox Code Playgroud)

为什么这个请求失败了?

(注意:我在send_file这里使用的全部原因是因为open显然只支持阅读...)

Eri*_*got 7

对于它的价值,替换send_file()set_contents_from_file()工作对我来说(我有同样的错误).