简体   繁体   中英

SignatureDoesNotMatch in aws s3 c# while getting presigned url

Hi I have mvc application in which I want to get url of uploaded image in amazon s3 but after getting url its not able to get open in browser code to get Url is

  var expiryUrlRequest = new GetPreSignedUrlRequest();
        expiryUrlRequest.BucketName = BUCKET_NAME;
        expiryUrlRequest.Key = "uploads/participantid_" + v1+ "/taskid_" + v2 + "/" + 0 + ".mp4";
        expiryUrlRequest.ContentType = "Video/mp4";
        expiryUrlRequest.Expires = DateTime.Now.AddYears(10);

     string    url = client.GetPreSignedURL(expiryUrlRequest);

I also get url but after pestling it into browser it show signature does not match.

After Generating Presigned URL and binding to html. Signature with hex value is changing to asci symbols.

Make sure to create signature for presigned url without hex value

Some suggestions:

  1. Specify the verb: expiryUrlRequest.Verb = HttpVerb.GET;
  2. Check the bucket policy whether the IAM role / AWS account whose access keys you are using to access this bucket, is allowed access to the bucket (use tool: https://awspolicygen.s3.amazonaws.com/policygen.html )
  3. Use an expiry which is less than 7 days (won't help in solving this issue, but the maximum allowed value is 7 days)
  4. Try ContentType as "video/mp4" (worth a shot).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM