title: Efficient way to upload multiple images to S3 from iOS
body: <p>I'm using Amazon S3 as my file storage system in the app. All my item objects have several images associated with them, and each stores only the image urls to keep my database lightweight. As such I need an efficient way to upload multiple images to S3 directly from iOS, and upon successful completion store their urls in the object I send to the server. I've perused the SDK and sample app Amazon provides, but the only example I've come across is for a single image upload, and goes as follows: </p>
  
  <pre><code> func uploadData(data: NSData) {
      let expression = AWSS3TransferUtilityUploadExpression()
      expression.progressBlock = progressBlock
  
      let transferUtility = AWSS3TransferUtility.defaultS3TransferUtility()
  
      transferUtility.uploadData(
          data,
          bucket: S3BucketName,
          key: S3UploadKeyName,
          contentType: "text/plain",
          expression: expression,
          completionHander: completionHandler).continueWithBlock { (task) -&gt; AnyObject! in
              if let error = task.error {
                  NSLog("Error: %@",error.localizedDescription);
                  self.statusLabel.text = "Failed"
              }
              if let exception = task.exception {
                  NSLog("Exception: %@",exception.description);
                  self.statusLabel.text = "Failed"
              }
              if let _ = task.result {
                  self.statusLabel.text = "Generating Upload File"
                  NSLog("Upload Starting!")
                  // Do something with uploadTask.
              }
  
              return nil;
      }
  }
  </code></pre>
  
  <p>For upwards of 5 images this will become a nested mess since I'd have to wait for each upload to return successfully before initiating the next, and then finally sending the object to my DB. Is there an efficient, code-clean for me to accomplish my goal? </p>
  
  <p>URL to Amazon's sample app github: <a href="https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3TransferUtility-Sample/Swift" rel="noreferrer">https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3TransferUtility-Sample/Swift</a></p>