请求签名我们计算的签名不匹配签名

huangapple go评论95阅读模式
英文:

The request signature we calculated does not match the signature

问题

我在升级AWSSDK.S3(3.7.107)至dot net core版本6.0后遇到了这个错误。对于dot net core 3.1,使用AWSSDK.S3(3.5.0.4)时,相同的代码可以正常工作。

var request = new GetPreSignedUrlRequest
{
    BucketName = "bucket-name-mobile/test",
    Key = "637431660687617131_Sachin_Pakale.jpg",
    Expires = DateTime.Now.AddDays(1)
};

url = s3Client.GetPreSignedURL(request);

发现后续版本将我的URL进行编码,将斜杠替换为%2F,使其无效。

<StringToSign>GET 1688208529 /bucket-name-mobile%2Ftest/637431660687617131_Sachin_Pakale.jpg</StringToSign>

我的存储桶名称包含斜杠,表示嵌套文件夹结构。是否有解决方法或选项可以避免这种编码?我正在使用USEast1区域。

英文:

I am getting this error after upgrading the AWSSDK.S3(3.7.107) for dot net core version 6.0.
The same code is working fine using AWSSDK.S3(3.5.0.4) for dot net core 3.1.

            var request = new GetPreSignedUrlRequest
            {
                BucketName = &quot;bucket-name-mobile/test&quot;,
                Key = &quot;637431660687617131_Sachin_Pakale.jpg&quot;,
                Expires = DateTime.Now.AddDays(1)
            };

            url = s3Client.GetPreSignedURL(request);

Found that the later version is encoding my URL by replaceing forward slash with %2F making it invalid.

&lt;StringToSign&gt;GET 1688208529 /bucket-name-mobile%2Ftest/637431660687617131_Sachin_Pakale.jpg&lt;/StringToSign&gt;

My bucket name has forward slashes being the nested folder structure.
Is there any workaround or provision to avoid this encoding? I am using USEast1 region.

答案1

得分: 1

桶名称不能包含斜杠。如果您的桶中包含名为“test”的文件夹,则需要修改您的键参数:

var request = new GetPreSignedUrlRequest
{
    BucketName = "bucket-name-mobile",
    Key = "test/637431660687617131_Sachin_Pakale.jpg",
    Expires = DateTime.Now.AddDays(1)
};

url = s3Client.GetPreSignedURL(request);
英文:

Bucket name can't contain slashes. If your bucket contains "the folder" called test, then you need to modify your key parameter:

var request = new GetPreSignedUrlRequest
{
    BucketName = &quot;bucket-name-mobile&quot;,
    Key = &quot;test/637431660687617131_Sachin_Pakale.jpg&quot;,
    Expires = DateTime.Now.AddDays(1)
};

url = s3Client.GetPreSignedURL(request);

huangapple
  • 本文由 发表于 2023年7月3日 16:55:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76603263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定