Amazon AWS GetPreSignedURL using C#

In this article, we will see how to create presigned url for amazon s3 object using c#.

To generate pre signed url for s3 object we should specify amont of time it should valid to access to users. After that the link will be not accessed to users.

This will promote the users to keep files/folders safe from accessing by anonymous users.

Here is the code to implement using c#.

 public string GetS3PreSignedUrl(string filekey)
     string url = "";
     if (!string.IsNullOrEmpty(filekey) && !string.IsNullOrWhiteSpace(filekey))
     using (IAmazonS3 client = new AmazonS3Client(AmazonAccessKey, AmazonSecretKey, RegionEndpoint.APSouth1))
      GetPreSignedUrlRequest request = new GetPreSignedUrlRequest();
      request.BucketName = "Give your BucketName";
      request.Key = filekey.TrimEnd('/');
      request.Verb = HttpVerb.GET;          
      request.Expires = DateTime.UtcNow.AddMinutes(10);
      url = client.GetPreSignedURL(request);
     return url;


Labels: Amazon AWS Get Pre Signed Url Using C#, aws presigned url, aws s3 pre signed url c#, GetPreSignedURL c#, aws GetPreSignedURL c#, amazon GetPreSignedURL using c#


Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker