How to retrieve url of the image uploaded on Amazon S3

Viewed 2946

I am new to Amazon S3. I want to upload all my images / PDF to S3 and let the user access those by using the URL. I am reading up the documentation and landed on this page:

http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpNET.html

This sample only uploads the image. How would I get the URL of the uploaded image so I can store them in my database and my user can use them to view the image?

For eg. Shouldn't it offer some url like http://aws.amazon.com/bucket-name/image-name.jpg and then I can type in that url in the browser and view my uploaded image from amazon.

Any help is appreciated.

2 Answers

Amazon don't give you the URL because the structure is already know before you upload a file.

http(s)://<bucket>.s3.amazonaws.com/<object>
http(s)://s3.amazonaws.com/<bucket>/<object>

You already know the bucket name, and the object name when you do the upload - S3 doesn't need to 'tell' you anything, you have the information - in fact you told S3 what the file name will be.

Related