2014-09-03 615 views
1

我有一個Rails應用4,我試圖配置Carrierwave與霧來上傳文件存儲在Amazon S3上,但我不斷收到以下錯誤:Carrierwave - 配置亞馬遜S3

Expected(200) <=> Actual(301 Moved Permanently) excon.error.response :body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message><RequestId>3C27ACF693820E4E</RequestId><Bucket>bucket_name</Bucket><HostId>8hnHAWoVEgsGkSyclME99rPTq5UHuSt6ZQ/ezmCRcuK+JUGWsSeI4FvcC2A5cym7</HostId><Endpoint>s3.amazonaws.com</Endpoint></Error>" :headers => { "Content-Type" => "application/xml" "Date" => "Wed, 03 Sep 2014 06:59:16 GMT" "Server" => "AmazonS3" "x-amz-id-2" => "8hnHAWoVEgsGkSyclME99rPTq5UHuSt6ZQ/ezmCRcuK+JUGWsSeI4FvcC2A5cym7" "x-amz-request-id" => "3C27ACF693820E4E" } :local_address => "10.0.0.9" :local_port => 54480 :remote_ip => "176.32.114.26" :status => 301 

配置/初始化/ carrierwave .rb:

CarrierWave.configure do |config| 
    config.fog_credentials = { 
    :provider    => 'AWS', 
    :aws_access_key_id  => 'XXXXXXXXXXXXXXXXXXXX', 
    :aws_secret_access_key => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
    :region     => 'us-east-1' 
} 
config.fog_directory = 'bucket_name' 
config.fog_public  = false 
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} 
end 

我也嘗試刪除:region參數(以及前面的逗號),但似乎並沒有工作。我檢查了存儲區域並將其列爲「美國標準」,但如果我查看端點,Amazon會將該存儲區域列爲us-east-1。無論如何,我已經嘗試將這兩個值分配給:region並且都不起作用。

有人能幫我弄清楚我做錯了什麼嗎?

回答

1

如果這可能會幫助別人節省幾個小時的時間,那麼解決方案證明我只是需要在修改文件後重新啓動服務器。

+0

謝謝幫助我!他們實際上應該將其添加到Carrierwave文檔中。我的意思是,我幾乎所有你用這個gem做的事情最好先運行ctrl + c然後rails第一個嘗試做任何錯誤,因爲它似乎修復了75%的錯誤。 – 2016-02-21 11:55:15