2

我正在利用 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;
        }];
    }
}
4

1 回答 1

0

您需要重新创建任务对象并再次重新启动任务。例如再次调用- upload:

于 2015-08-14T23:39:12.353 回答