I am trying to set up AWS, and carrierwave to upload pictures from my website. I keep getting the error 'missing required option :name' when I try to upload/update the posts though. I have followed tutorials to set up my S3 account and to get carrierwave.rb set up. Please let me know if you have any ideas!
carrierwave.rb
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = ENV['S3_BUCKET_NAME']
config.aws_acl = 'public-read'
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
config.aws_attributes = {
expires: 1.week.from_now.httpdate,
cache_control: 'max-age=604800'
}
config.aws_credentials = {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION']
}
end
.env example
S3_BUCKET_NAME=*****
AWS_ACCESS_KEY_ID=*****
AWS_SECRET_ACCESS_KEY=*****
AWS_REGION=*****
portfolio_uploader.rb
class PortfolioUploader < CarrierWave::Uploader::Base
storage :aws
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
I ran into this issue too. The error message is deceptive. I found that it is actually the config.aws_bucket = ENV['S3_BUCKET_NAME']
line that was causing the issue. If config.aws_bucket
is nil
(such as when the ENV['S3_BUCKET_NAME']
is unset, you will get the deceptive missing required option :name
in the console.
I had an identical issue, try to restart the rails server, when you are making any changes to your config folder you have to restart the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With