我有我的應用程序在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