Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display image which is stored on s3 without storing on harddisk?

In my rails app I have used attachment_fu to upload images and stored it on s3. I want to display these images on browser without retrieving it. How can I display images by giving s3 path?

Thanks, Jayashri

like image 883
Jayashri Avatar asked Jan 12 '11 16:01

Jayashri


1 Answers

You just need to link to the correct S3 path for you images.

For public files they are in the format:

eg http://s3.amazonaws.com/[bucket]/[key]

If your content is private you'll need to create a signed url but all the SDKs and libraries make this easy.

Then use the url to display the images:

<img src="http://s3.amazonaws.com/mybucket/myfile.jpg"  ... ></img>
like image 122
Geoff Appleford Avatar answered Sep 28 '22 05:09

Geoff Appleford