views:

29

answers:

2

I'm somewhat new to S3. I'm wondering 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?

+1  A: 

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.

Steve Ross
+1  A: 

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.

tfe