Reputation: 207
I am trying to access the file that has been uploaded to Amazon S3 by using the method GetPreSignedUrlRequest. The code I am using is as below:-
string bucketName = string.Empty;
if (ConfigurationManager.AppSettings["S3BucketName"] != null)
{
bucketName = ConfigurationManager.AppSettings["S3BucketName"].ToString();
}
AmazonS3Client s3Client = new AmazonS3Client(Amazon.RegionEndpoint.USEast1);
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
{
BucketName = bucketName,
Key = file.FileName,
Expires = DateTime.Now.AddMinutes(5),
Protocol = Protocol.HTTP
};
string url = s3Client.GetPreSignedURL(request);
The url generated by this is then used to point to the file. It looks like http://s3.amazonaws.com/mybucketname/VZcbKsZgR2qyOMkLU1XT_jquery_ui_touch-punch_min_js.txt?X-Amz-Expires=300&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIMGQJ6D5L5SNBGHA/20140114/us-east-1/s3/aws4_request&X-Amz-Date=20140114T194159Z&X-Amz-SignedHeaders=host&X-Amz-Signature=922719dd2286600aebaca5701a8e142d327342b541569c9a4d7d8afc822d9a76/VZcbKsZgR2qyOMkLU1XT_jquery_ui_touch-punch_min_js.txt
But that gives me signature doesnot match error as shown in the image below:-
Upvotes: 2
Views: 1847
Reputation: 8180
This can also occur if some of the details about the request are not set up properly:
e.g. For me the following lines fixed the problem
request1.ContentType = "image/jpeg";
request1.Verb = HttpVerb.PUT;
Upvotes: 0
Reputation: 734
Update - version 2.0.6 of the SDK, released Jan 16th, contains a fix for this issue.
Your code is fine, unfortunately a bug in the SDK is causing the presigned url to be malformed. I've just tested it with our latest codebase and we've fixed the issue; this new version should be released soon.
I'll ping this issue once we release the patch. Sorry for the inconvenience.
Regards,
Upvotes: 0