gpt4 book ai didi

ios - iOS AWS S3 Upload如何重试失败或失败的任务?

转载 作者:行者123 更新时间:2023-12-01 16:30:20 25 4
gpt4 key购买 nike

我正在利用iOS AWS开发工具包的批处理上传[AWSTask taskForCompletionOfAllTasks:tasks] tasks数组是AWSTask *task = [self.transferManager upload:uploadRequest];对象的数组。上传完成后,我可以枚举数组以检查所有任务是否成功。但是,我似乎无法弄清楚如何重试失败或错误的任务。如果我将失败的任务数组传递给taskForCompletionOfAllTasks,它对那些任务没有任何作用?

iOS AWS docs它没有提及有关重试失败或错误任务的任何内容。是的,有AWSServiceConfiguration.maxRetryCount,但是在超过该数量后无法解决重试错误或失败的任务的问题。而且iOS AWS Examples对此也没有显示任何内容。

- (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;
}];
}
}

最佳答案

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

关于ios - iOS AWS S3 Upload如何重试失败或失败的任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31994456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com