So, I'm trying to upload an image from the Rails API to S3, using Fog.
Whenever I try to upload the image, I get this:
Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden)
(...)
All access to this object has been disabled
It is working in development, but once I switch to production, I receive the error above. I'm using the keys from an user I've created that set full administrative permissions to.
My carrierwave.rb: require 'carrierwave'
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => "AWS",
:region => "us-east-1",
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
if Rails.env.production?
config.cache_dir = "#{Rails.root}/tmp/uploads"
end
config.fog_directory = ENV['AWS_BUCKET']
config.fog_public = false
end
Any ideas? Thanks in advance! :)
Always make sure you have the right ENV variables and the the correct S3 keys.
This was the problem in my case.
In my case the problem was related to the ENV on Heroku. I forgot to add the REGION variable.
So, it's worth checking if you have all your variables set correctly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.