使用 carrierwave/fog 上传到 aws s3 时已禁用对此对象的所有访问
All Access to this object has been disabled when using carrierwave/fog to upload to aws s3
我尝试上传到 s3 时遇到此错误。我检查以确保我的 aws 凭据正确。这是我遇到的错误。
```
Excon::Errors:`:Forbidden: Expected(200) <=> Actual(403 Forbidden)
excon.error.response
:body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AllAccessDisabled</Code><Message>All access to this object has been disabled</Message><RequestId></RequestId><HostId></HostId></Error>"
:cookies => [
]
:headers => {
"Connection" => "close"
"Content-Type" => "application/xml"
"Date" => "Fri, 13 May 2016 22:14:48 GMT"
"Server" => "AmazonS3"
"x-amz-id-2" => ""
"x-amz-request-id" => ""
}
:host => "s3.amazonaws.com"
:local_address => "10.0.0.24"
:local_port => 57133
:path => "/uploads/script/file/1/Facebook-2006.jpg"
:port => 443
:reason_phrase => "Forbidden"
:remote_ip => "54.231.114.148"
:status => 403
:status_line => "HTTP/1.1 403 Forbidden\r\n"
```
这就是我配置的方式 carrierwave/fog
config/initializer/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
provider: "AWS",
aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
}
config.fog_directory = ENV["AWS_S3_BUCKET"]
end
存储桶是否有public访问权限?如果可以,您可以尝试在 fog 配置中设置存储桶的 AWS 区域?
愚蠢的举动。我将存储桶名称设置错误。我写了 ENV["AWS_S3_BUCKET"] 而不是 ENV['S3_BUCKET_NAME']。它说访问被拒绝可能是因为它试图访问一个不存在的存储桶或者是 s3 的根目录。
我尝试上传到 s3 时遇到此错误。我检查以确保我的 aws 凭据正确。这是我遇到的错误。
```
Excon::Errors:`:Forbidden: Expected(200) <=> Actual(403 Forbidden)
excon.error.response
:body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AllAccessDisabled</Code><Message>All access to this object has been disabled</Message><RequestId></RequestId><HostId></HostId></Error>"
:cookies => [
]
:headers => {
"Connection" => "close"
"Content-Type" => "application/xml"
"Date" => "Fri, 13 May 2016 22:14:48 GMT"
"Server" => "AmazonS3"
"x-amz-id-2" => ""
"x-amz-request-id" => ""
}
:host => "s3.amazonaws.com"
:local_address => "10.0.0.24"
:local_port => 57133
:path => "/uploads/script/file/1/Facebook-2006.jpg"
:port => 443
:reason_phrase => "Forbidden"
:remote_ip => "54.231.114.148"
:status => 403
:status_line => "HTTP/1.1 403 Forbidden\r\n"
```
这就是我配置的方式 carrierwave/fog
config/initializer/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
provider: "AWS",
aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
}
config.fog_directory = ENV["AWS_S3_BUCKET"]
end
存储桶是否有public访问权限?如果可以,您可以尝试在 fog 配置中设置存储桶的 AWS 区域?
愚蠢的举动。我将存储桶名称设置错误。我写了 ENV["AWS_S3_BUCKET"] 而不是 ENV['S3_BUCKET_NAME']。它说访问被拒绝可能是因为它试图访问一个不存在的存储桶或者是 s3 的根目录。