英文:
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 = "bucket-name-mobile/test",
Key = "637431660687617131_Sachin_Pakale.jpg",
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.
<StringToSign>GET 1688208529 /bucket-name-mobile%2Ftest/637431660687617131_Sachin_Pakale.jpg</StringToSign>
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 = "bucket-name-mobile",
Key = "test/637431660687617131_Sachin_Pakale.jpg",
Expires = DateTime.Now.AddDays(1)
};
url = s3Client.GetPreSignedURL(request);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论