Some questions about setting up Amazon S3 with Ruby on Rails
I'm trying to setup Amazon S3 hosting with my Ruby on Rails 3 app, which is hosted on Heroku. After reading these instructions in the Heroku docs, I'm trying to use the aws-s3 gem.
The instructions say to put the S3 account details in config/amazon_s3.yml
, but the aws-s3 Github page says you create a connection like this:
AWS::S3::Base.establish_connection!(
:access_key_id => 'abc',
:secret_access_key =&开发者_运维问答gt; '123'
)
Why is the connection created by providing the details if they're already provided in the config file? Is that not the correct way to establish a connection? Do I have to establish a connection for each user everytime an upload is about to occur, or is a connection established for the application as a whole?
Thanks for reading.
You're reading documentation for different gems. If you use Attachment-Fu or Paperclip, they'll manage S3 connection internally and you need to only provide credentials. If you access S3 directly (through aws-s3 gem), you'll need to establish connection explicitly.
精彩评论