Ruby on Rails: Error uploading images to Amazon S3 with paperclip and fog
I'm using the gems of ' fog ' and 'paperclip' to upload images to s3, but every time I throw the request to my API to save the image it throws me a warning in the terminal:
[fog] [WARNING] fog: followed redirect to s3-eu-west-1.amazonaws.com, connecting to the matching region will be more performing
And my model is configured like this:
has_attached_file :avatar,
:storage => :fog,
:fog_credentials => {
:provider => 'AWS',
:aws_access_key_id => access_key_id,
:aws_secret_access_key => secret_access_key,
:region => 'eu-west-1',
:path_style => true
},
:fog_directory => "bucket",
:fog_region => 'eu-west-1'
I don't know if the error is because I'm sending an image in base64 or some error in Amazon S3
5
1 answers
You must remove the option :fog_region
, you already have it specified in :fog_credentials
, this will stop displaying the warnings.
Example:
config.paperclip_defaults = {
:storage => :fog,
:fog_credentials => {
:provider => "AWS",
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
:region => 'eu-west-1',
},
:fog_directory => ENV["S3_BUCKET_NAME"]
}
end
1
Author: Fulvio, 2016-03-15 13:29:55