【发布时间】:2012-02-20 15:52:02
【问题描述】:
我使用 Paperclip 设置了一个应用程序来解决用户头像的问题。我想在亚马逊 s3 上存储文件。我找不到这个问题的解决方案,所以最后我决定在这里问:
这是用户模型中的连接设置:
has_attached_file :avatar,
:styles => { :small => "150x150#", :medium => "300x300#" },
:storage => :s3,
:s3_credentials => Rails.root.join('config/s3.yml')
那么这里是s3.yml文件:
bucket: sghub
access_key_id: ###
secret_access_key: #####
当然在我的 gemfile 中我已经添加了:
gem 'paperclip'
gem 'aws-s3', :require => 'aws/s3'
应用程序部署在 Heroku 上,所以我从 heroku logs 命令得到的错误是这样的:
2012-02-20T07:13:58+00:00 app[web.1]: AWS::S3::PermanentRedirect (The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.)
同样在开发模式下,错误页面如下:
Errno::EINVAL in UsersController#update
Invalid argument
此外,文件似乎没有在 s3 上上传,因为它们在我的存储桶的管理控制台中不可见。我现在几乎不知道,因为我试图设置所有教程和文档中的所有内容。有什么想法吗?
【问题讨论】:
标签: ruby-on-rails amazon-s3 paperclip