简体   繁体   English

使用carrierwave / fog上传到aws s3时,已禁用对此对象的所有访问

[英]All Access to this object has been disabled when using carrierwave/fog to upload to aws s3

I'm getting this error when I try to upload to s3. 尝试上传到s3时出现此错误。 I checked to make sure my aws credentials were correct. 我检查以确保我的AWS凭证正确。 Here's the error that i'm getting. 这是我得到的错误。

``` ```

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"

``` ```

And this is how I configured 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 这就是我配置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 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

Idiot move. 蠢货。 I was setting the name of the bucket name wrong. 我设置的存储桶名称错误。 I wrote ENV["AWS_S3_BUCKET"] instead of ENV['S3_BUCKET_NAME']. 我写了ENV [“ AWS_S3_BUCKET”]而不是ENV ['S3_BUCKET_NAME']。 It was saying access denied probably because it was trying to access a bucket that doesn't exist or is the root of s3. 有人说访问被拒绝,可能是因为它试图访问一个不存在或不是s3根的存储桶。

Does the bucket has public access permissions? 该存储桶是否具有公共访问权限? and if it does you can try and set the AWS region of your bucket in the configuration of fog? 是否可以尝试在fog的配置中设置存储桶的AWS区域?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM