我正在开发一个Rails 3应用程序,它允许用户上传他们的个人资料图片。我已经遵循了许多在线配置,并且认为我离使它工作非常接近,但是由于某些原因我似乎无法将文件传输到Amazon存储桶中。
以下是我的设置:
用户模型有以下内容:
has_attached_file :photo,
:styles => {:small => "83x83>"},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => "/:style/:filename",
:bucket => 'mybucket'
我的yml文件如下所示:
development:
bucket: "dev"
access_key_id: "kjlkjlkjlkjlkjlkjlkj"
secret_access_key: "kjlkjlkjlkjlkjlkjlkj/kjlkjlkjlkjlkjlkjlkj"
test:
bucket: "test"
access_key_id: "kjlkjlkjlkjlkjlkjlkj"
secret_access_key: "kjlkjlkjlkjlkjlkjlkj/kjlkjlkjlkjlkjlkjlkj"
production:
bucket: "prod"
access_key_id: "kjlkjlkjlkjlkjlkjlkj"
secret_access_key: "kjlkjlkjlkjlkjlkjlkj/kjlkjlkjlkjlkjlkjlkj"
我的控制器中的操作执行了这个功能
def upload_image
current_user.update_attributes(params[:user])
redirect_to "/profile/#{current_user.id}"
end
我在Rails控制台中检查了user.photo对象,但在:errors参数中没有看到任何东西。 在这一点上,我感到相当困惑。 我使用我的FTP程序(Transmit)使用相同的凭据连接到S3帐户,并且工作正常,因此我确信我的配置是正确的。