title: Control uploads to S3 using BFTask and AWS SDK iOS v2
body: <p>I am using <a href="https://github.com/BoltsFramework/Bolts-iOS" rel="nofollow">BFTask</a> together with <a href="https://github.com/aws/aws-sdk-ios-v2" rel="nofollow">AWS SDK v2</a> for iOS to upload and download files to AWS S3 storage. The following code works very well but I am wondering if anyone know how I can gain more control over the maximum number of uploads to allow and also better approach to receiving feedback for upload progress. I have read the documentation for both AWS SDK v2, the source code, and the BFTask readme but I am still uncertain how I gain control. For example, how would I edit the following code to limit the number of BFTasks to be run simultaneously to 3 and also receive number of bytes currently uploaded out of total number of bytes? </p>
  
  <pre><code>-(void) uploadAllFileRequests
  {
      AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
      __block int uploadCount = 0;
      __block int uploadSuccess= 0;
      __block int uploadFailure= 0;
  
      NSMutableArray *tasks = [NSMutableArray new];
      unsigned long totalnumberoffiles=self.arrayOfUploadRequests.count;
  
      for (__block AWSS3TransferManagerUploadRequest *uploadRequestLocal in self.arrayOfUploadRequests)
      {
  
          [tasks addObject:[[transferManager upload:uploadRequestLocal] continueWithBlock:^id(BFTask *task) {
              if (task.error != nil) {
                   if( task.error.code != AWSS3TransferManagerErrorCancelled
                     &amp;&amp;
                     task.error.code != AWSS3TransferManagerErrorPaused
                     )
                  {
                      NSLog(@"ERROR: %@",StatusLabelFailed);
                      uploadFailure ++;
                  }
              } else {
                  uploadCount ++;
                  uploadSuccess ++;
                  NSLog(@"ETag: %@           %@ : %3.2f",[task.result valueForKey:@"ETag"], StatusLabelUploading, (uploadCount*1.0/totalnumberoffiles)*100.);
              }
              return nil;     
          }]];
      }
      [[BFTask taskForCompletionOfAllTasks:tasks] continueWithSuccessBlock:^id(BFTask *task)
       {
           NSLog(@"Finished:  Success: %i - Failed: %i  -",uploadSuccess,uploadFailure);
           return nil;
       }];
  }
  </code></pre>
  
  <p>Here <code>self.arrayOfUploadRequests</code> is an array containing <code>AWSS3TransferManagerUploadRequest</code>. Suggestions are greatly appreciated. Thanks!</p>