Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 获取文件头需要什么AWS S3权限?_Ruby_Amazon S3_Fog - Fatal编程技术网

Ruby 获取文件头需要什么AWS S3权限?

Ruby 获取文件头需要什么AWS S3权限?,ruby,amazon-s3,fog,Ruby,Amazon S3,Fog,我正在使用名为Fog的Ruby Gem来访问S3,我正在尝试收紧权限。我正在做的事情之一是: storage.files.head(文件名) 其中存储是这样获得的: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action":[ "s3:ListBucket"], "Resource": ["arn:aws:s3:::bucket-name"]

我正在使用名为Fog的Ruby Gem来访问S3,我正在尝试收紧权限。我正在做的事情之一是:

storage.files.head(文件名)

其中存储是这样获得的:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action":[
        "s3:ListBucket"],
      "Resource": ["arn:aws:s3:::bucket-name"]
    },
    {
      "Effect": "Allow",
      "Action":[
        "s3:DeleteObject",
        "s3:GetObject",
        "s3:PutObject"],
      "Resource": ["arn:aws:s3:::bucket-name/*"]
    }
  ]
}
storage=Fog::storage.new(AWS\U凭据)。directories.new(键:“bucket name”)

不幸的是,此操作失败,出现以下错误:

#<Excon::Response:0x00000101aa8050 @data={:body=>"", :headers=>{"x-amz-request-id"=>"1BD5F221BD5F22", "x-amz-id-2"=>"rh9CJHBQW+1uY/Ajki/m1jzpYacyhrh9CJHBQW+1uY/Ajki/m1jzpYacyh", "Content-Type"=>"application/xml", "Transfer-Encoding"=>"chunked", "Date"=>"Wed, 13 Aug 2014 01:12:25 GMT", "Connection"=>"close", "Server"=>"AmazonS3"}, :status=>403, :remote_ip=>"178.178.178.178", :local_port=>58870, :local_address=>"10.0.0.1"}, @body="", @headers={"x-amz-request-id"=>"1BD5F221BD5F22", "x-amz-id-2"=>"rh9CJHBQW+1uY/Ajki/m1jzpYacyhrh9CJHBQW+1uY/Ajki/m1jzpYacyh", "Content-Type"=>"application/xml", "Transfer-Encoding"=>"chunked", "Date"=>"Wed, 13 Aug 2014 01:12:25 GMT", "Connection"=>"close", "Server"=>"AmazonS3"}, @status=403, @remote_ip="178.178.178.178", @local_port=58870, @local_address="10.0.0.1">

是否知道我缺少哪些权限或如何查找?

解决方案是将s3:ListBucket权限添加到bucket中,如下所示:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action":[
        "s3:ListBucket"],
      "Resource": ["arn:aws:s3:::bucket-name"]
    },
    {
      "Effect": "Allow",
      "Action":[
        "s3:DeleteObject",
        "s3:GetObject",
        "s3:PutObject"],
      "Resource": ["arn:aws:s3:::bucket-name/*"]
    }
  ]
}