Rails Paperclip S3 ArgumentError (missing required :bucket option):

旧巷老猫 提交于 2019-12-01 09:30:15

Here is my paperclip initialization stuff:

Paperclip::Attachment.default_options.merge!({
    storage: :s3,
    s3_credentials: {
        access_key_id: ENV['S3_KEY'],
        secret_access_key: ENV['S3_SECRET'],
        bucket: "#{ENV['S3_BUCKET']}-#{Rails.env}"
        },
    url: ":s3_domain_url",
    path: "/:class/:attachment/:id_partition/:style/:filename"
    })

This assumes that we have three environment variables setup called, you guessed it... S3_KEY, S3_SECRET, and S3_BUCKET. I did a little trick so that I could have a different bucket in each environment by adding Rails.env to the bucket variable.

You seem to indicate in your question that you're putting the actual name of the bucket in the reference to ENV, which would not work. You should put the name of the bucket in the environment variable and use the name of the environment variable as the key.

I hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!