无法使用雾宝石更新回形针附件到s3

时间:2014-03-21 15:47:15

标签: ruby-on-rails amazon-s3 paperclip fog

我正在尝试将图片上传到s3,但我遇到了这个错误 “缺少必需的参数:aws_access_key_id,aws_secret_access_key”

class MyModel < ActiveRecord::Base

has_attached_file :attachment,
  :storage => :fog,
  :fog_credentials => {:provider => "AWS",
                       access_key_id: 'key_id',secret_access_key: 'access_key'},
  :fog_directory => 'bucket_name'

end

1 个答案:

答案 0 :(得分:1)

使用aws_access_key_id中的aws_secret_access_keyfog_credentials选项代替access_key_idsecret_access_key

has_attached_file :attachment,
  :storage => :fog,
  :fog_credentials => {:provider => "AWS",
                       aws_access_key_id: 'key_id',aws_secret_access_key: 'access_key'},
  :fog_directory => 'bucket_name'

请参阅 fog_credentials options

列表