"missing required :bucket option" for Paperclip/S3 "missing required :bucket option" for Paperclip/S3 heroku heroku

"missing required :bucket option" for Paperclip/S3


I think that's because :bucket should be an option passed to Paperclip not to S3.
Fixed config

  config.paperclip_defaults = {    :storage => :s3,    :s3_protocol => 'http',    :bucket => ENV['AWS_BUCKET'],    :s3_credentials => {      :access_key_id => ENV['AWS_ACCESS_KEY_ID'],      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']    }  }

And Paperclip::Storage::S3 doc seems to confirm that, even being so poorly written/formatted.

EDIT:

In one of my projects I use Paperclip with Fog gem and this works well

Paperclip::Attachment.default_options.merge!(  :storage => :fog,  :fog_credentials => {    :provider => 'AWS',    :aws_access_key_id => ENV['S3_ACCESS_KEY_ID'],    :aws_secret_access_key => ENV['S3_SECRET_ACCESS_KEY'],    :region => 'eu-west-1' # in case you need it  },  :fog_directory => ENV['S3_BUCKET'], # only one of those is needed but I don't remember which  :bucket => ENV['S3_BUCKET'])


In my case it was that I was using foreman (Heroku) which uses an .env file to store environment variables. So, when I did rake db:migrate it couldn't find the ENV['AWS_ACCESS_KEY_ID']

What I did to run my migration was I temporarily added my AWS credentials directlñy into Carrierwave config block and then removed them after...

This is not a permanent solution because next time you migrate it will say the same thing...

For the permanent solution see: Use environment variables in Rake task

which says use: foreman run rake some_task this way all variables defined in .env are loaded for the rake task too


Add this to your application.rb file inside the module and class. create a local_env.yml file and put your environment variables in there. This code will load your environment variables on server start :

config.autoload_paths += %W(#{config.root}/lib)config.before_configuration do    env_file = File.join(Rails.root, 'config', 'local_env.yml')    YAML.load(File.open(env_file)).each do |key, value|        ENV[key.to_s] = value    end if File.exists?(env_file)end