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

标签 ios amazon-s3 aws-sdk amazon-cognito awss3transfermanager

我正在利用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/

相关文章:

ios - 根据指定的年龄范围过滤用户。解析和 Swift

ios - 使用Objective C在iOS中使用公钥加密或签名字符串

ios - 在 sprite kit 中使用渐变效果将 fps 从 60 降低到 30

java - 如何连接 Apache Kafka 和 Amazon S3?

java - amazon swf flow 框架中自动生成的代码抛出语法错误

node.js - 如何在 AWS Cognito 的用户池中获取用户的额外属性

ios - 尝试将 Facebook Messenger 集成到 iOS 应用程序时出现 "FBAPIErrorDomain error 404"

python - 如何从 Glue 作业填充的 S3 存储桶中删除重复值

amazon-s3 - AWS S3 存储桶策略源 IP 不起作用

当用户从多个设备登录时,Android AWS Cognito UserPool globalSignout 不起作用