title: Show Upload Progress for Image Upload to Amazon S3 using Swift 3 and Amazon SDK
body: <p>I am able to successfully upload an image to Amazon S3, but I can't seem to figure out how to show the progress of it doing so.</p>
  
  <p>I'm currently uploading like so.</p>
  
  <pre><code>import UIKit
  import MapKit
  import CoreData
  import AWSCore
  import AWSCognito
  import AWSS3
  import MobileCoreServices
  import AWSMobileAnalytics
  </code></pre>
  
  <p>in my upload button I have the following code...</p>
  
  <pre><code>let myIdentityPoolId = "us-west-2:dca2beb4-9a67-etc....etc..."
                  let credentialsProvider:AWSCognitoCredentialsProvider = AWSCognitoCredentialsProvider(regionType: AWSRegionType.usWest2, identityPoolId: myIdentityPoolId)
                  let configuration = AWSServiceConfiguration(region: AWSRegionType.usWest2, credentialsProvider: credentialsProvider)
                  AWSServiceManager.default().defaultServiceConfiguration = configuration
  
  self.uploadImage(filename)
  </code></pre>
  
  <p>This is the uploadImage function...</p>
  
  <pre><code>func uploadImage(filename:String){
          print("AWS Upload Image Attempt...")
          //defining bucket and upload file name
          let S3BucketName: String = "distribution-tech-mobile-live"
          let filepath = "\(AppDelegate.appDelegate.applicationDocumentsDirectory())/\(filename)"
          let imageURL = URL(fileURLWithPath: filepath)
          let S3UploadKeyName = filename //TODO: Change this later
  
          let uploadRequest = AWSS3TransferManagerUploadRequest()
          uploadRequest?.bucket = S3BucketName
          uploadRequest?.key = filename
          uploadRequest?.contentType = "image/jpeg"
          uploadRequest?.body = imageURL
          uploadRequest?.serverSideEncryption = AWSS3ServerSideEncryption.awsKms
          uploadRequest?.uploadProgress = { (bytesSent, totalBytesSent, totalBytesExpectedToSend) -&gt; Void in
              DispatchQueue.main.async(execute: {
                  self.amountUploaded = totalBytesSent // To show the updating data status in label.
                  self.fileSize = totalBytesExpectedToSend
                  print("\(totalBytesSent)/\(totalBytesExpectedToSend)")
              })
          }
  
          self.uploadCompletionHandler = { (task, error) -&gt; Void in
              DispatchQueue.main.async(execute: {
                  if ((error) != nil){
                      print("Failed with error")
                      print("Error: \(error!)");
                  }
                  else{
                      print("Sucess")
                  }
              })
          }
  
          let transferUtility = AWSS3TransferUtility.default()
          let expression = AWSS3TransferUtilityUploadExpression()
  
          transferUtility.uploadFile(imageURL, bucket: S3BucketName, key: S3UploadKeyName, contentType: "image/jpeg", expression: expression, completionHander: uploadCompletionHandler).continue({ (task) -&gt; AnyObject! in
              if let error = task.error {
                  print("Error: \(error.localizedDescription)")
              }
              if let exception = task.exception {
                  print("Exception: \(exception.description)")
              }
              if let _ = task.result {
                  print("Upload Starting!")
              }
  
              return nil;
          })
  
      }
  </code></pre>
  
  <p>I got the code for image uploading progress from another thread but there solution doesn't seem to work or I'm misunderstanding it.</p>
  
  <p><a href="https://stackoverflow.com/questions/40348696/upload-image-aws-s3-bucket-in-swift?rq=1">Upload image AWS S3 bucket in swift</a>, and this thread (<a href="https://stackoverflow.com/questions/35240317/swift-aws-s3-upload-image-from-photo-library-and-download-it">Swift - AWS S3 Upload Image from Photo Library and download it</a>).  They both have 2 different ways to do it, the last link I couldn't get its way to work either.</p>
  
  <p>I'm not sure what I'm doing wrong.</p>