Building URL point to object in AWS S3 Bucket

In response to Adding item to AWS S3 Bucket

After adding an object to AWS S3 Bucket, you would want to have a easy method of retrieving back the object.
As such below is a snippet on the building of a expiring Url that point to the object in AWS S3.

string accessKey = "KEY HERE";
string secretKey = "KEY HERE";
AmazonS3 client;
using (var s3Client = AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey, RegionEndpoint.APSoutheast1))
{
GetPreSignedUrlRequest requestR = new GetPreSignedUrlRequest();
requestR.BucketName = "MyBucket";
request.Key = "images/" + filename;  //unique identifier of your object in S3
requestR.Protocol = Protocol.HTTP;
requestR.Expires = DateTime.Now.AddYears(10);

result = s3Client.GetPreSignedURL(requestR);
}

Note: This uses Amazon SDK v2.0.0.3

Advertisements
This entry was posted in AWS and tagged , , . Bookmark the permalink.

One Response to Building URL point to object in AWS S3 Bucket

  1. Pingback: Adding item to AWS S3 Bucket | TechCentral

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s