【发布时间】:2012-12-03 08:37:59
【问题描述】:
我的应用程序在 heroku 上运行,并已配置为使用 Amazon s3 将所有上传到存储桶的资产保存。一切正常。因此,当我尝试在本地(开发)上传图像时,出现以下错误
AWS::S3::Errors::PermanentRedirect in RecipesController#update
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
我的更新操作
def update
@recipe = Recipe.find(params[:id])
if @recipe.update_attributes(params[:recipe])
redirect_to my_recipes_path, :notice => "Successfully updated recipe"
else
render :action => 'edit'
end
end
虽然经过一番阅读,这似乎是因为我在欧盟使用了一个存储桶(不是默认的美国存储桶)
我有两个存储桶,一个用于开发,一个用于生产。并创建了一个 s3.yml 文件来保存凭据,尽管我认为使用 ENV 变量会更好,我使用 Ubuntu 并且可以更新我的 .bashrc 文件?不确定那个.. 无论如何我的 s3.yml 文件(为安全起见删除了实际密钥)
development:
access_key_id: KEY
secret_access_key: KEY
bucket: assets.recipesappdev
production:
access_key_id: KEY
secret_access_key: KEY
bucket: assets.recipesapp
还有我的配方模型配置
has_attached_file :avatar,
:styles => { :myrecipes => "260x180#", :showrecipe => "600x300#", :medium => "300x300>", :thumb => "100x100>" },
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "/images/:id/:style.:extension"
有没有人解决这个问题,我试过这个,例如 http://www.conandalton.net/2011/02/paperclip-s3-and-european-buckets.html 但这不起作用,虽然我的初始化程序可能是错误的,但我尝试配置以适合我的应用程序
Paperclip.interpolates(:s3_eu_url) { |assets, style|
"#{assets.s3_protocol}://s3-eu-west-1.amazonaws.com/#{assets.recipesappdev} /#{assets.path(style).gsub(%r{^/}, "")}"
}
【问题讨论】:
-
这里有问题的解释:devcenter.heroku.com/articles/…
标签: ruby-on-rails-3 heroku amazon-s3 paperclip