I am trying to use CarrierWave with Amazon S3. When I try to upload a file, through a rake task, I get this error:
rake aborted!
Expected(200) <=> Actual(403 Forbidden)
My CarrierWave initializer looks like this:
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: MY_AWS_ACCESS_KEY_ID,
aws_secret_access_key: MY_AWS_SECRET_ACCESS_KEY
}
config.fog_directory = MY_BUCKET
config.fog_public = true
end
I do have real, hard-coded key/secret/bucket values set while I'm debugging this.
The rake task looks like this, and is successful when I have the CarrierWave uploader set to upload locally with storage: file
:
Photo.create({
image: File.new('lib/dummy_files/image.jpg')
})
Any help is much appreciated. Thanks!
I realized this has to do with the new AWS Identity and Access Management (IAM). I had created a new IAM user, but I hadn't given that user the correct privileges. In the past, there was only one user, and that user had admin privileges. Now you have to create a user, give that user the correct privileges, and use that user's credentials. I hope this helps someone.
This answer helped me too ... specifically, it's under IAM > Users > Permissions > Attach User Policy
When you first create a user it gets no 'user policies' under 'permissions.' Once I attached a user policy things worked.
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