Rails 3 - Amazon S3 Paperclip EU Problem

你说的曾经没有我的故事 提交于 2019-11-30 03:53:47

Did you try this workaround?

Paperclip et les European S3 buckets

Or even this one?

Paperclip, S3, and European Buckets

You don't need to work around the EU Problem anymore.

The default aws-s3 storage backend in paperclip was replaced by the AWS SDK for Ruby, that is also the amazon recommended way when working with AWS.

Just insert

gem 'aws-sdk'

into your Gemfile and run bundle install.

If you want something like https://s3-eu-west-1.amazonaws.com/some_path_goes_here, try to configure your model's has_attached_file with the following options

:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:s3_permissions => :private,
:s3_protocol => 'https',
:s3_host_name => 's3-eu-west-1.amazonaws.com',
:path => ":filename"

If you don't want to use https you can remove the :s3_protocol and if you want to change the region, option :s3_host_name is the right way to go. You can also put this into a configuration file.

Hope this helps.

I added

Paperclip::Attachment.default_options[:s3_host_name] = 's3-eu-west-1.amazonaws.com'

to paperclip.rb in the initializers folder and it works fine for me.

Same problem here, just solved passing the following option to has_attached_file:

:url => ':s3_domain_url' 

For more info see here http://rubydoc.info/gems/paperclip/Paperclip/Storage/S3 :

Normally, this won't matter in the slightest and you can leave the default (which is path-style, or :s3_path_url). But in some cases paths don't work and you need to use the domain-style (:s3_domain_url).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!