Rails paperclip and Amazon S3 'PermanentRedirect'

I am trying to use paperclip and amazon s3. My bucket is in the 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.

It is very annoying, I tried to fix it, but I think that I will die, I continue to try.

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 put the calling format 10 minutes ago for the last test, but nothing changed

 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 the file here, feel free to tell me. Does anyone have an idea?

thank

EDIT: Now I have this error:

getaddrinfo: nodename nor servname provided, or not known

... I really don't know

+4
1

, url: ":s3_domain_url", : http://www.rubydoc.info/gems/paperclip/Paperclip/Storage/S3

. , :

# 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: "___", }, }

0

Source: https://habr.com/ru/post/1544205/


All Articles