python - 预签名 URL:发布图像错误:签名不匹配:Python
问题描述
- 我将在 lambda 中执行以下命令以生成预签名 URL
'''
import boto3
from botocore.client import Config
def lambda_handler(event, context):
s3 = boto3.client('s3', config=Config(signature_version='s3v4'))
url = s3.generate_presigned_url(
'put_object',
Params={
'Bucket': 'XXX-profile',
'Key': 'test',
'ContentType': 'image/jpeg',
'ACL': 'public-read'},
ExpiresIn=600
)
return url
''' 2. 一旦我得到 URL,我就会尝试从邮递员那里发布图片
你能帮忙看看我的错误在哪里吗..我找不到。
解决方案
尝试从. ACL
_ 这些不适用于方法。Content-Type
Params
generate_presigned_url
import boto3
from botocore.client import Config
def lambda_handler(event, context):
s3 = boto3.client('s3', config=Config(signature_version='s3v4'))
url = s3.generate_presigned_url(
'put_object',
Params={
'Bucket': 'XXX-profile',
'Key': 'test',
},
ExpiresIn=600
)
return url
如果还想设置 content-type 和 ACL,请尝试使用该generate_presigned_post
方法。
推荐阅读
- html - 如果在 css 网格中使用百分比,则错误 safari div 的大小计算
- javascript - 如何通过 API 控制器使用 Ajax 将对象列表加载到选择标签中?
- javascript - 在二叉搜索树Javascript的画布上定位圆
- delphi - 如何从窗口句柄中获取可执行文件名?
- docker - 一个 pod 中的容器与多容器 pod 中的一个容器进行通信
- reactjs - 保存数据库中数组项的位置
- javascript - 如果第二条是黑色的,如何只发送一条消息,但如果我填写了两个变量,如何发送两条消息?
- ios - 单击按钮添加其他文本字段不起作用
- sql - Where 子句和 Join on 子句中的别名
- javascript - TypeError:部署在 Heroku 上的 Strapi 应用仅支持绝对 URL