I try to use paperclip and Amazon s3. My bucket is in EU (Ireland) And I got this error :
AWS::S3::Errors::PermanentRedirect in MyControllerController
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
This is very annoying, I tried to fix this but I think I'm gonna die keep trying.
So this is my code :
s3.yml
access_key_id: *****
secret_access_key: ****
bucket: mybucketname
AWS_CALLING_FORMAT: s3-eu-west-1-amazonaws.com #not sure for this one
I've put the calling format 10 min ago for a last test, but nothing change
config/initializers/paperclip.rb
Paperclip.options[:command_path] = "/usr/local/bin/"
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3-eu-west-1-amazonaws.com'
and so, my model :
has_attached_file :attachment,
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "pictures/:id/:style.:extension",
:bucket => 'mybucketname'
and finally
# in config/initializers/something.rb
Paperclip.interpolates(:s3_eu_url) { |assets, style|
"#{assets.s3_protocol}://s3-eu-west-1.amazonaws.com/#{assets.recipesappdev} /#{assets.path(style).gsub(%r{^/}, "")}"
}
So, If I forgot to put a file here, don't hesitate to tell me. Anybody has an idea ?
Thanks
EDIT : Now I have this error :
getaddrinfo: nodename nor servname provided, or not known
... Really no idea
I believe you want to set the url: ":s3_domain_url"
as in this documentation: http://www.rubydoc.info/gems/paperclip/Paperclip/Storage/S3
Here's my configuration. I'm not sure if you need all of it like the path or region:
# development.rb config.paperclip_defaults = { storage: :s3, url: ":s3_domain_url", path: ":class/:id/:attachment/:style.:extension", s3_region: "us-east-2", s3_credentials: { bucket: "whoops-proof-dev", access_key_id: "___", secret_access_key: "___", }, }
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.