Rails 3 - Amazon S3 回形针欧盟问题 [英] Rails 3 - Amazon S3 Paperclip EU Problem
问题描述
我正在使用:
Paperclip 2.3.16
Rails 3.0.9
Ruby 1.9.2
AWS - S3 0.6.2
我正在尝试使用回形针上传到基于欧盟(爱尔兰)的存储桶.我的模型中有以下内容:
I'm trying to use paperclip the upload to the EU (Ireland) based bucket. I have the following in my model:
has_attached_file :image, :styles => { :grid => '90x128#', :list => '140x200#', :original => '400x548'},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:url => 'flyers/:id/:style/:basename.:extension',
:path => 'flyers/:id/:style/:basename.:extension',
:bucket => 'fsight'
在我的 environment.rb 中,我已通过以下方式将写入设置为使用 AWS/s3 默认主机到相关的欧盟:
In my environment.rb I have set the write to use the AWS/s3 Default Host to the relevant EU one by using:
require "aws/s3"
AWS::S3::DEFAULT_HOST.replace "s3-eu-west-1.amazonaws.com"
这很好用,它允许我上传图片,我可以使用 AWS 管理控制台验证图片上传/删除.
This works fine, and it allows me to upload the images, and I can verify the image upload / delete using the AWS Management consoler.
但是,我在尝试在我的网站上显示图像时遇到了问题.图像无法加载,我已确定原因,因为生成的 URL 使用旧的默认主机.例如:
However, I have a problem when trying to display the images on my site. The images do not load and I have identified the cause, as the URL generated uses the old default host. Eg:
应该是什么:https://s3-eu-west-1.amazonaws.com/fsight/flyers/50/full/4759543368588654950.jpg
实际上是什么: http://s3.amazonaws.com/fsight/flyers/50/full/4759543368588654950.jpg?1314801178
如您所见,它使用旧的默认主机.
As you can see, it uses the old default host.
我试过放置:
Paperclip.interpolates(:s3_eu_url) do |att, style|
"#{att.s3_protocol}://s3-eu-west-1.amazonaws.com/#{att.bucket_name}/#{att.path(style)}"
end
但随后开始收到以下错误:
But then started receiving the following error:
wrong number of arguments (0 for 1)
Extracted source (around line #9):
<img src= <%= @event.image.url(:original) %>
我知道 Paperclip 在使用 EU Buckets 时遇到了一些问题,但有人可以帮我解决这个问题吗?
I know Paperclip has some issues with using EU Buckets, but could anybody help me with this?
推荐答案
你试过这个解决方法吗?
Did you try this workaround?
还是这个?
这篇关于Rails 3 - Amazon S3 回形针欧盟问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!