开发者

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

开发者 https://www.devze.com 2023-02-03 16:58 出处:网络
In my rails app I have used attachment_fu to upload images and stored it on s3. I want to display开发者_StackOverflow社区 these images on browser without retrieving it.

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

Thanks, Jayashri


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>


It may help you to install the S3 organizer in Firefox so you can browser your directories. Then I believe the URL's are structured kinda like this...

http://BUCKET.s3.amazonaws.com/FOO/BAR.png

0

精彩评论

暂无评论...
验证码 换一张
取 消