开发者

is it good to use S3 for Rails "public/images" and there an easy way to do it?

I'm somewhat new to S3. I'm wondering 开发者_JAVA百科if it's a good idea to put public/images in S3 bucket and if so is there an easy way to do the move?


If you look in config/environments/production.rb, you'll see the following line of code (commented out):

config.action_controller.asset_host = "http://assets.example.com"

If you want to keep your assets (images, stylesheets, etc.) on S3, just put the correct url there. You might be interested in this from Amazon:

http://developer.amazonwebservices.com/connect/message.jspa?messageID=159916

and this in the Rails API:

http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html

Asset hosts are good if you are serving up a bunch of static assets or storing bulky ones on expensive servers. If you're low volume or are serving up small assets, then S3 might not make sense. By the way, Paperclip understands S3, so it's a natural attachment-handling gem for this kind of thing.


Unless you're storing very large or extremely-frequently-accessed assets in public/, there's no reason to put that on an external asset host. It'd be a needless increase in the complexity of your app.

If you do have large or frequently-accessed assets, you probably want to be using Amazon's CloudFront content distribution network in addition to S3.

Steve Ross's answer is good for the Rails-side how-to.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜