2
我正在使用iOS AWS SDK的批量上傳[AWSTask taskForCompletionOfAllTasks:tasks]
tasks
數組是一個AWSTask *task = [self.transferManager upload:uploadRequest];
對象的數組。一旦上傳完成,我可以枚舉整個數組來檢查所有任務是否成功。但是,我似乎無法弄清楚如何重試失敗或故障的任務。如果我將一組失敗的任務傳遞給taskForCompletionOfAllTasks
,那麼對這些任務不做任何處理?iOS AWS S3上傳如何重試失敗或故障任務?
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;
}];
}
}
有沒有辦法從故障或失敗的任務中提取數據(密鑰,存儲桶,主體)?如果不能單獨跟蹤這些數據,然後試圖從中創建一個全新的任務,那將是非常麻煩的。想象一下,我正在批量上傳100多個文件,任務失敗或出錯,並且您說我不能簡單地重試該失敗的任務。所以,我需要以某種方式找出哪些文件包含故障任務,然後用這些數據創建一個全新的任務。 – sudo