我正在利用 iOS AWS SDK 的批量上传[AWSTask taskForCompletionOfAllTasks:tasks]
该tasks
数组是一个AWSTask *task = [self.transferManager upload:uploadRequest];
对象数组。上传完成后,我可以枚举数组以检查所有任务是否成功。但是,我似乎无法弄清楚如何重试失败或出错的任务。如果我将一系列失败的任务传递给taskForCompletionOfAllTasks
它,这些任务不会做任何事情吗?
iOS AWS 文档没有提及重试失败或错误任务的任何内容。是的,AWSServiceConfiguration.maxRetryCount
但是在超出计数后重试错误或失败的任务并不能解决问题。iOS AWS 示例也没有显示任何关于此的内容。
- (void)performS3UploadWithRequest:(NSArray *)tasks withRetryCount:(int)retryCount
{
if (retryCount == 0) {
alert = [[UIAlertView alloc] initWithTitle:@"Failed to Upload Content"
message:@"It appears we are having issues uploading your card information."
delegate:self cancelButtonTitle:nil
otherButtonTitles:@"Retry Upload", @"Retry Later", @"Cancel Order", nil];
[alert show];
} else {
[[AWSTask taskForCompletionOfAllTasks:tasks] continueWithExecutor:[AWSExecutor mainThreadExecutor] withBlock:^id(AWSTask *task) {
NSMutableArray *faultedTasks = [NSMutableArray new];
for (AWSTask *finishedTask in tasks) {
if (finishedTask.cancelled || finishedTask.faulted) {
[faultedTasks addObject:finishedTask];
}
}
if (faultedTasks.count > 0) {
[self performS3UploadWithRequest:faultedTasks withRetryCount:retryCount-1];
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:kWHNotificationUploadDone object:self userInfo:nil];
}
return nil;
}];
}
}