我正在尝试创建一个预签名的URL,以帮助一些客户上传文件。这是我目前正在运行的测试脚本
# 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'
到Params
(或在从服务器收到的put_object文档中的信息之后添加一些元数据:
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
github问题https://github.com/boto/boto3/issues/934中对此进行了介绍
要上传对象,应使用generate_presigned_post。URL中无法嵌入多个参数,这些参数将通过该方法返回给您。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句