【问题标题】:Uploading large files using S3TransferManager AWS iOS SDK使用 S3TransferManager AWS iOS 开发工具包上传大文件
【发布时间】:2014-04-23 02:03:19
【问题描述】:

我正在尝试使用 S3TransferManager 将视频从 iPhone 上传到 AWS S3。它适用于小文件,但对于较大的文件,我收到此错误:

Error Domain=com.amazonaws.iossdk.ServiceErrorDomain Code=400 "The operation couldn’t be completed. (com.amazonaws.iossdk.ServiceErrorDomain error 400.)" UserInfo=0x16ed0600 {requestId=856937B6CD6E14DE, exception=AmazonServiceException { RequestId:856937B6CD6E14DE, ErrorCode:InvalidRequest, Message:Key is not expected for the GET method ?uploads subresource }, errorCode=InvalidRequest}

据我了解,S3TransferManager 将文件分解为大文件的分段上传,然后出现问题。

我目前的政策:

{
"Version": "2012-10-17",
"Statement": [
{
"Action":"s3:ListBucketMultipartUploads",
"Resource":"arn:aws:s3::: my_bucket_name",
"Effect": "Allow"
},
{
"Action": ["s3:PutObject","s3:PutObjectAcl","s3:PutObjectVersionAcl","s3:GetObject","s3:ListMultipartUploadParts","s3:AbortMultipartUpload"],
"Resource": ["arn:aws:s3:::my_bucket_name/*"],
"Effect": "Allow"
}
]
}

要上传的代码是:

S3PutObjectRequest *putObjectRequest = [[S3PutObjectRequest alloc] initWithKey:my_key inBucket: my_bucket_name];
    [putObjectRequest setFilename:videoMetaData.videoFilePath];

    [putObjectRequest addMetadataWithValue:[UserSessionInfo sharedSessionInfo].userEmail forKey:@"email"];
    [putObjectRequest addMetadataWithValue:[UtilHelper formatDuration:videoMetaData.length] forKey:@"videolength"];
    [putObjectRequest addMetadataWithValue:@"Landscape" forKey:@"orientation"];
    [putObjectRequest addMetadataWithValue:[NSString stringWithFormat:@"%d", data.length] forKey:@"size"];

    putObjectRequest.contentType = @"video/quicktime";
    self.uploadFileOperation = [self.s3TransferManager upload:putObjectRequest];

我们将不胜感激。

【问题讨论】:

    标签: ios amazon-web-services sdk multipart


    【解决方案1】:

    您似乎缺少s3:GetObjectAcl 权限?

    我还创建了两个单独的策略,一个用于存储桶,另一个用于内容。

    存储桶政策

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "Stmt1398382003000",
          "Effect": "Allow",
          "Action": [
            "s3:ListBucketMultipartUploads"
          ],
          "Resource": [
            "arn:aws:s3:::uploads"
          ]
        }
      ]
    }
    

    文件政策

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "Stmt1398382057000",
          "Effect": "Allow",
          "Action": [
            "s3:AbortMultipartUpload",
            "s3:GetObject",
            "s3:GetObjectAcl",
            "s3:ListMultipartUploadParts",
            "s3:PutObject",
            "s3:PutObjectAcl",
            "s3:PutObjectVersionAcl"
          ],
          "Resource": [
            "arn:aws:s3:::uploads/*"
          ]
        }
      ]
    }
    

    我遇到了同样的问题,上述政策对我有用。

    【讨论】:

    • 注意,我的错误略有不同:Domain=com.amazonaws.iossdk.ServiceErrorDomain Code=403 "The operation couldn’t be completed. (com.amazonaws.iossdk.ServiceErrorDomain error 403.)" UserInfo=0x188e9450 {requestId=F9E4C8C64994806A, exception=AmazonServiceException { RequestId:F9E4C8C64994806A, ErrorCode:AccessDenied, Message:Access Denied }, errorCode=AccessDenied}
    猜你喜欢
    • 1970-01-01
    • 2015-08-14
    • 2023-03-15
    • 2020-10-29
    • 1970-01-01
    • 2015-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多