Ruby on Rails 4 - Paperclip AWS 图像 URL 错误? [英] Ruby on Rails 4 - Paperclip AWS Image URL is wrong?
问题描述
我之前一起使用过回形针和 AWS,但我刚刚创建了这个 Rails 4 应用程序,我的 image.url 方法显示在 'http://s3.amazonaws.com/',当它应该在 's3-us-west-2.amazonaws.com' 上寻找它们时.我假设这是因为第一个帐户的区域是美国标准,而新帐户是俄勒冈.
I've used paperclip and AWS together before, but I just created this Rails 4 app, and my image.url method is showing looking for the image at 'http://s3.amazonaws.com/', when it should be looking for them at 's3-us-west-2.amazonaws.com'. I'm assuming this is because the region for the first account is US Standard, whereas the new one is Oregon.
我有什么方法可以更改配置文件中的区域或其他内容吗?
Any way for me to change the region in the config files or something?
推荐答案
显然过去有很多解决方法,但现在配置中有一个名为 s3_host_name 的选项.
Apparently there used to be a bunch of workarounds for this, but now there is an option in the config called s3_host_name.
ExampleApp:Application.configure do
config.paperclip_defaults = {
:storage => :s3,
:s3_host_name => 's3-us-west-2.amazonaws.com',
:s3_credentials => {
:bucket => '#',
:access_key_id => '#',
:secret_access_key => '#'
}
}
end
这篇关于Ruby on Rails 4 - Paperclip AWS 图像 URL 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!