signature=0ce9fb0941877fb321c7a5fe5457598a,错误:我们计算的请求签名与您提供的签名不匹配。(Error: The request signature we c...

I'm trying to perform an AWS upload on iOS. I'm looping through an array of AWSS3TransferManagerUploadRequest objects and uploading a lot of images (1000+) of varying size to an S3 bucket. Using:

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

[[transferManager upload:request] continueWithExecutor:[BFExecutor mainThreadExecutor]

withBlock:^id(BFTask *task) {

Once I get to about the 700th image the upload progress starts get really slow and then I start receiving these errors on every other subsequent image upload:

2015-03-27 11:07:30.238 crafted[4979:1414229] Error: Error Domain=com.amazonaws.AWSGeneralErrorDomain Code=3 "The operation couldn’t be completed. (com.amazonaws.AWSGeneralErrorDomain error 3.)" UserInfo=0x1709b5b60 {SignatureProvided=f8c21dd55c323378b05c660a5f27255a2aecbd6eee1f2ca0c5fb0460136dde30, RequestId=DB37767F9C1AFD7E, StringToSign=AWS4-HMAC-SHA256-PAYLOAD

20150327T160658Z

20150327/us-west-2/s3/aws4_request

1e63d8ac434ee08f333a4f59c52fc3565e5b451cca9c7f1a946e209fb72f24c5

e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

11b7db18ee4cbdedc46907daa5e99688b2be72da3a943ac0354a9405b7c59f19, Code=SignatureDoesNotMatch, HostId=0V4bjdhjCG/wt/NAlsgr1K7DV6QkUdYOlwjFRfmBI/swFesufXVi19PTgacwOBt1, StringToSignBytes=41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 2d 50 41 59 4c 4f 41 44 0a 32 30 31 35 30 33 32 37 54 31 36 30 36 35 38 5a 0a 32 30 31 35 30 33 32 37 2f 75 73 2d 77 65 73 74 2d 32 2f 73 33 2f 61 77 73 34 5f 72 65 71 75 65 73 74 0a 31 65 36 33 64 38 61 63 34 33 34 65 65 30 38 66 33 33 33 61 34 66 35 39 63 35 32 66 63 33 35 36 35 65 35 62 34 35 31 63 63 61 39 63 37 66 31 61 39 34 36 65 32 30 39 66 62 37 32 66 32 34 63 35 0a 65 33 62 30 63 34 34 32 39 38 66 63 31 63 31 34 39 61 66 62 66 34 63 38 39 39 36 66 62 39 32 34 32 37 61 65 34 31 65 34 36 34 39 62 39 33 34 63 61 34 39 35 39 39 31 62 37 38 35 32 62 38 35 35 0a 31 31 62 37 64 62 31 38 65 65 34 63 62 64 65 64 63 34 36 39 30 37 64 61 61 35 65 39 39 36 38 38 62 32 62 65 37 32 64 61 33 61 39 34 33 61 63 30 33 35 34 61 39 34 30 35 62 37 63 35 39 66 31 39,

AWSAccessKeyId=ASIAJCSIGUTUKG2HSYCA,

Message=The request signature we calculated does not match the signature you provided. Check your key and signing method.}

"The request signature we calculated does not match the signature you provided. Check your key and signing method."

I have no idea why this is happening and I am unable to find a similar Q/A on this issue.

Edit: I am using Cognito Identity pool to authenticate and provide anonymous access to the s3 bucket for puts only.

Edit 2: Code Per Yosuke's request (I simply build out an array of requests objects then loop through the array and upload each request):

- (void)performS3UploadWithRequest:(NSMutableArray *)requests

{

for (AWSS3TransferManagerUploadRequest *request in requests) {

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

__weak typeof(self) weakSelf = self;

[[transferManager upload:request] continueWithExecutor:[BFExecutor mainThreadExecutor]

withBlock:^id(BFTask *task) {

if (task.error) {

if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {

switch (task.error.code) {

case AWSS3TransferManagerErrorCancelled:

case AWSS3TransferManagerErrorPaused:

break;

default:

NSLog(@"Error: %@", task.error);

break;

}

} else {

// Unknown error.

NSLog(@"Error: %@", task.error);

}

}

if (task.result) {

AWSS3TransferManagerUploadOutput *uploadOutput = task.result;

// The file uploaded successfully.

NSLog(@"%@", uploadOutput);

[weakSelf countUploadProgress];

}

return nil;

}];

}

}

- (AWSS3TransferManagerUploadRequest *)createUploadRequestWithDestinationBucket:(NSString *)destBucket Key:(NSString *)key Body:(NSURL *)body

{

AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];

uploadRequest.bucket = destBucket;

uploadRequest.key = key;

uploadRequest.body = body;

uploadRequest.contentType = @"binary/octet-stream";

uploadRequest.uploadProgress = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {

dispatch_async(dispatch_get_main_queue(), ^{

if (totalBytesExpectedToSend > 0) {

NSLog(@"%f", (float)((double) totalBytesSent / totalBytesExpectedToSend));

}

});

};

return uploadRequest;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值