BOTO3-为put_object返回的generate_presigned_url返回我们计算出的请求签名与您提供的签名不匹配。

路卡

我正在尝试创建一个预签名的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_postURL中无法嵌入多个参数,这些参数将通过该方法返回给您。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章