我刚刚遇到了这个问题,因为我没有在请求中提供正确的区域。
我根据 railscast here 使用 fog 和 Carrierwave,我必须在配置/初始化程序中为 Carrierwave 配置区域
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS', # required
aws_access_key_id: '[redacted]', # required unless using use_iam_profile
aws_secret_access_key: '[redacted]', # required unless using use_iam_profile
# use_iam_profile: false, # optional, defaults to false
region: 'eu-central-1', # optional, defaults to 'us-east-1'
# host: 's3.example.com', # optional, defaults to nil
# endpoint: 'https://s3.example.com:8080' # optional, defaults to nil
}
config.fog_directory = 'xxx' # required
# config.fog_public = false # optional, defaults to true
# config.fog_attributes = { cache_control: "public, max-age=#{365.days.to_i}" } # optional, defaults to {}
end
有趣的是,amazon 将雾重定向到具有正确区域的正确端点,但是,重定向的请求在身份验证时失败,在这种情况下可能是雾的问题。雾确实在日志中给出了一个很好的警告
[fog][WARNING] fog: followed redirect to calm4-files.s3.amazonaws.com, connecting to the matching region will be more performant
但为了更准确,他们应该说not only more performant, but it will actually work as well