aws ios sdk - 从s3

时间:2016-04-07 01:26:10

标签: ios swift amazon-s3 aws-sdk aws-ios

我正在尝试使用iOS sdk(swift)从我的s3存储桶下载图像,但我总是收到access-denied错误

Domain=com.amazonaws.AWSS3ErrorDomain Code=1 "(null)" UserInfo={HostId=asadadadadadad=, Message=Access Denied, Code=AccessDenied, RequestId=A467438974F8127B}]

当我不使用任何ACL设置时,上传工作正常。如果我设置ACL

 let uploadRequest = AWSS3TransferManagerUploadRequest()
 uploadRequest.ACL = AWSS3ObjectCannedACL.AuthenticatedRead

上传和播放下载失败。

下面是我的认知& IAM政策

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

{
  "Version":"2012-10-17",
  "Statement":[
    {
      "Sid":"AddCannedAcl",
      "Effect":"Allow",
      "Principal": "*",
     "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Resource":["arn:aws:s3:::yimages/*"]
    }
  ]
}

我确信这是政策的结果,但是我无法弄清楚是什么......令我困惑的是上传的工作方式如何下载?

任何帮助都非常感谢..

1 个答案:

答案 0 :(得分:0)

  1. GetObject& PutObject指的是对桶内对象的操作。不适用于桶(arn:aws:s3 ::: yimages)。对于存储桶本身,您需要提供如下所示的存储桶操作:
  2. "Action": [
                "s3:GetBucketLocation",
                "s3:ListBucket",
                "s3:ListAllMyBuckets"
            ]
    
    1. 您可以尝试将类似的政策添加到“权限”标签的显式“广告管理政策”部分,以指定广告代码和广告代码。对象级权限