Exitos
Exitos

Reputation: 29750

How do I generate an amazon S3 file url?

I have created the file in an amazon S3 bucket. I know that the url format is:

http://ptedotnet.s3-eu-west-1.amazonaws.com/UserContent/Uploads/54/26.jpg

However I want to be able to work out what the 's3-eu-west-1' bit is without having to explicitly know this in my application. I have seen that in the API there is a call which I can make to get the location...

GetBucketLocationRequest bucketRequest = new GetBucketLocationRequest();
            bucketRequest.BucketName = ConfigurationManager.AppSettings["AWS_Bucket"].ToString();
            GetBucketLocationResponse ree = client.GetBucketLocation(bucketRequest);
            string location = ree.Location;

But this only returns 'eu' so im wondering how to get the other parts. The less the user has to configure on the application the better :-)

Upvotes: 1

Views: 4975

Answers (2)

user1906709
user1906709

Reputation: 31

Use S3SignURL to make a signed URL

Upvotes: 0

Nigel Whatling
Nigel Whatling

Reputation: 2391

You can just use {bucket}.s3.amazonaws.com.

i.e. http://ptedotnet.s3.amazonaws.com/UserContent/Uploads/54/26.jpg

Upvotes: 3

Related Questions