You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用预签名URL上传至AWS S3时遇键异常及签名不匹配问题

AWS S3预签名URL上传文件问题

操作流程

生成预签名URL

生成图片文件的预签名URL命令:

aws s3 presign s3://mybucket/something1.png --expires-in 7200

生成PDF文件的预签名URL命令:

aws s3 presign s3://mybucket/CV.pdf --expires-in 7200

注:当前存储桶未配置任何策略

初始上传测试

使用以下curl命令上传文件:

curl "presign-url" --upload-file ~/Desktop/CV.pdf
curl "presign-url" --upload-file ~/Desktop/something1.png

执行后两种场景均出现异常:对象键(Key)末尾被添加了多余的反斜杠\

带请求头的上传测试

尝试添加Content-Type请求头后重新上传:

curl -T ~/Desktop/something1.png -H "Content-Type: image/png" "presign-url"

触发SignatureDoesNotMatch错误,错误详情如下:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>签名不匹配</Code>
    <Message>我们计算的请求签名与您提供的签名不匹配。请检查您的密钥和签名方法。</Message>
    <AWSAccessKeyId>已脱敏</AWSAccessKeyId>
    <StringToSign>AWS4-HMAC-SHA256
20240522T160714Z
20240522/eu-west-2/s3/aws4_request
已脱敏</StringToSign>
    <SignatureProvided>已脱敏</SignatureProvided>
    <StringToSignBytes>已脱敏</StringToSignBytes>
    <CanonicalRequest>PUT
/hich.survey.images/something1.png
X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=已脱敏%2F20240522%2Feu-west-2%2Fs3%2Faws4_request&amp;X-Amz-Date=20240522T160714Z&amp;X-Amz-Expires=3600&amp;X-Amz-SignedHeaders=host
host:s3.eu-west-2.amazonaws.com

host
UNSIGNED-PAYLOAD</CanonicalRequest>
    <CanonicalRequestBytes>已脱敏</CanonicalRequestBytes>
    <RequestId>6QYT5HRK2RYE6PQF</RequestId>
    <HostId>已脱敏</HostId>
</Error>

内容的提问来源于stack exchange,提问作者Farzin Nasiri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 12:02:41