有关使用 Ruby on Rails 设置 Amazon S3 的一些问题
我正在尝试使用托管在 Heroku 上的 Ruby on Rails 3 应用程序设置 Amazon S3 托管。阅读 Heroku 文档中的这些说明后,我尝试使用 aws-s3宝石。
说明表示将 S3 帐户详细信息放入 config/amazon_s3.yml< /code>,但是 aws-s3 Github 页面 说您创建了一个如下连接:
AWS::S3::Base.establish_connection!(
:access_key_id => 'abc',
:secret_access_key => '123'
)
为什么如果配置文件中已提供详细信息,则通过提供详细信息来创建连接?这不是建立连接的正确方法吗?我是否必须在每次上传时为每个用户建立连接,还是为整个应用程序建立连接?
感谢您的阅读。
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 => '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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在阅读不同宝石的文档。如果您使用 Attachment-Fu 或 Paperclip,它们将在内部管理 S3 连接,您只需提供凭据。如果您直接访问 S3(通过 aws-s3 gem),则需要显式建立连接。
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.