简体   繁体   English

ASP.NET Core ASW S3 - 我们计算的请求签名与您提供的签名不匹配

[英]ASP.NET Core ASW S3 - The request signature we calculated does not match the signature you provided

I am getting this error when I try to upload a file to the bucket.当我尝试将文件上传到存储桶时出现此错误。

This is my code.这是我的代码。

 public async Task UploadFileAsync(IFormFile file, string userId)
    {
        var filePath = Path.GetFullPath(file.FileName);
        var bucketName = this.configuration.GetSection("Amazon")["BucketName"];
        var accessKey = this.configuration.GetSection("Amazon")["AWSAccessKey"];
        var secretKey = this.configuration.GetSection("Amazon")["AWSSecretKey"];
        var bucketRegion = RegionEndpoint.EUWest1;

        var s3Client = new AmazonS3Client(accessKey, secretKey, bucketRegion);

        try
        {
            var fileTransferUtility =
                new TransferUtility(s3Client);

            using (var newMemoryStream = new MemoryStream())
            {
                file.CopyTo(newMemoryStream);

                var uploadRequest = new TransferUtilityUploadRequest
                {
                    InputStream = newMemoryStream,
                    Key = file.FileName,
                    BucketName = bucketName,
                    CannedACL = S3CannedACL.PublicRead,
                };

                await fileTransferUtility.UploadAsync(uploadRequest);
            }

            await this.filesRepository.AddAsync(new FileBlob
            {
                Name = file.FileName,
                Extension = file.FileName.Split('.')[1],
                Size = file.Length,
                UserId = userId,
                UploadedOn = DateTime.UtcNow,
            });
            await this.filesRepository.SaveChangesAsync();
        }
        catch (AmazonS3Exception e)
        {
            Console.WriteLine(e.Message);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }

Razor: here Razor: 这里

It always says "The request signature we calculated does not match the signature you provided. Check your key and signing method."它总是说“我们计算的请求签名与您提供的签名不匹配。请检查您的密钥和签名方法。”

Any ideas?有任何想法吗?

The problem was the mistaken accessKey and secretKey.问题是错误的 accessKey 和 secretKey。 After I got them right all I had to do is change the CannedACL = S3CannedACL.BucketOwnerFullControl .在我把它们做对之后,我所要做的就是改变CannedACL = S3CannedACL.BucketOwnerFullControl That solved it for me这为我解决了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们计算的请求签名与您提供的签名不匹配 aws - the request signature we calculated does not match the signature you provided aws C# + Google Storage 签名网址:我们计算的请求签名与您提供的签名不匹配 - C# + Google Storage signed URL: The request signature we calculated does not match the signature you provided 亚马逊MWS | RestSharp | 我们计算出的请求签名与您提供的签名不匹配 - Amazon MWS | RestSharp | The request signature we calculated does not match the signature you provided 签名可写 URL 错误:我们计算的请求签名与您提供的签名不匹配 - Error with signed writable URL: The request signature we calculated does not match the signature you provided SQS 客户端验证异常 - 我们计算的请求签名与您提供的签名不匹配 - SQS Client Validation Exception - The request signature we calculated does not match the signature you provided WordPress WooCommerce ASP.net:“ms-signature”标头字段提供的WebHook签名与接收者期望的值不匹配 - WordPress WooCommerce ASP.net: The WebHook signature provided by the 'ms-signature' header field does not match the value expected by the receiver 签名与S3不匹配 - Signature does not Match S3 C#AWS SQS请求签名与提供的签名不匹配 - C# AWS SQS request signature does not match the signature provided ASP.NET Core 中使用 JSON 的 AngularJS API 请求的方法签名 - Method signature in ASP.NET Core for AngularJS API request with JSON 带有Azure B2C的ASP.NET Core 2 Jwt身份验证// IDX10500:签名验证失败。 没有提供安全密钥来验证签名 - ASP.NET Core 2 Jwt Auth with Azure B2C // IDX10500: Signature validation failed. No security keys were provided to validate the signature
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM