4

I need to send a file with the parameters and tracking the progress of uploading. Method

Alamofire.request(.POST, "http://httpbin.org/post", parameters: parameters, encoding: .JSON)

don't track progress uploading. Method

Alamofire.upload(.POST, "http://httpbin.org/post", file: fileURL)
     .progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in
         println(totalBytesWritten)
     }
     .responseJSON { (request, response, JSON, error) in
         println(JSON)
     }

is not able to set the parameters

is it possible to send a file with the parameters and tracking the progress of uploading?

bpa
  • 183
  • 1
  • 12

2 Answers2

2

You have to use .uploadProgress instead of .progress.

Colin Wang
  • 6,778
  • 5
  • 26
  • 42
0

Use this way

    activeVidoeCell.uploadRequest = Alamofire.upload(fileData as Data, to: url, method: .put, headers: nil).uploadProgress(closure: { (progress) in

        print(progress.fractionCompleted)
        activeVidoeCell.downloadButton.setProgress(CGFloat(progress.fractionCompleted), animated: true)

    }).responseJSON(completionHandler: { (result) in

        completionHandler(result)

    })
Bucket
  • 449
  • 3
  • 20