【发布时间】:2014-09-03 07:09:28
【问题描述】:
我有一个 Rails 4 应用程序并尝试配置 Carrierwave 和 Fog 以在 Amazon 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
config/initializers/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 参数(连同前面的逗号),但这似乎也不起作用。我检查了存储桶区域,它被列为“美国标准”,但如果我查看端点,亚马逊将该存储桶列为 us-east-1。无论如何,我已经尝试将这两个值都分配给 :region ,但都没有成功。
谁能帮我弄清楚我做错了什么?
【问题讨论】:
标签: ruby-on-rails amazon-s3 carrierwave fog