2

I'm utilizing the iOS AWS SDK's batch upload [AWSTask taskForCompletionOfAllTasks:tasks] The tasks array is an array of AWSTask *task = [self.transferManager upload:uploadRequest]; objects. Once the upload is complete I can enumerate through the array to check to see if all the tasks were successful or not. However, I can't seem to figure out how to retry a failed or faulted task. If I pass an array of failed tasks to taskForCompletionOfAllTasks it doesn't do anything with those tasks?

The iOS AWS docs it doesn't mention anything about retrying on failed or faulted task. Yes, there is the AWSServiceConfiguration.maxRetryCount but that doesn't solve the issue with retrying faulted or failed tasks after that count as been exceeded. Also the iOS AWS Examples don't show anything in regards to this either.

- (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;
        }];
    }
}
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
sudo
  • 1,648
  • 1
  • 20
  • 22

1 Answers1

0

You need to recreate the task object and reinitiate the task again. e.g. calling - upload: again.

Yosuke
  • 3,759
  • 1
  • 11
  • 21
  • 1
    Is there a way I can extract the data (key, bucket, body) from the faulted or failed task? It would be very cumbersome to have to try and keep track of that data separately and then attempt to create a whole new task from that if that task failed. Imagine I'm bulk uploading 100s of files and a task failed or faulted, and you're saying I can't simply retry that failed task. So, I then need to somehow figure out what file that faulted task contained and then create a whole new task with that data. – sudo Aug 20 '15 at 18:19