BOTO3-为put_object返回的generate_presigned_url返回我们计算出的请求签名与您提供的签名不匹配. [英] BOTO3 - generate_presigned_url for `put_object` return `The request signature we calculated does not match the signature you provided`
问题描述
我正在尝试创建一个预签名的url,它将帮助一些客户上传文件. 这是我目前正在运行的测试脚本
I'm trying to create a presigned url that will help some customers to upload files . Here my test script that is currently working
# Get the service client.
s3 = boto3.client('s3')
boto3.set_stream_logger(name='botocore')
# Generate the URL to get 'key-name' from 'bucket-name'
url = s3.generate_presigned_url(
ClientMethod='put_object',
Params={
'Bucket': s3_bucket_name,
'Key': test_key,
}
)
files = StringIO("asdfasdfasdf")
response = requests.put(url, data=files)
print(str(response.content))
但是,如果我要添加:
`ACL': 'public-read'
to Params
(or add some metadata following the information in the put_object documentation I receive back from the server:
The request signature we calculated does not match the signature you provided. Check your key and signing method.
我还在BOTO3上打开了一个问题: https://github.com/boto/boto3/issues/1722
I've open also a issue on BOTO3: https://github.com/boto/boto3/issues/1722
推荐答案
在github问题
对于上传对象,您应该使用 generate_presigned_post . url中无法嵌入几个参数,这些参数会通过该方法返回给您.
For uploading an object, you should use generate_presigned_post. There are several parameters that cannot be embedded within the url, and those are returned to you by that method. 这篇关于BOTO3-为put_object返回的generate_presigned_url返回我们计算出的请求签名与您提供的签名不匹配.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!