我有我的应用程序在heroku上运行,并配置为使用亚马逊s3保存上传到存储桶的所有资产。所有工作正常。所以,当我试图在本地上传图片(开发)我得到以下错误使用回形针和亚马逊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文件(实际密钥的安全删除obviosuly)
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{^/}, "")}"
}
两者这里有问题的解释:https://devcenter.heroku.com/articles/paperclip-s3#international-users-additional-configuration – TTT