Alamofire uploads progress

I need to send a file with parameters and track the progress of the download. Method

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

      

do not track the loading of the process. 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)
     }

      

cannot set parameters

Can I send a file with parameters and track the download progress?

+3


source to share


2 answers


You must use . uploadProgress instead of .progress .



+1


source


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)

    })

      

0


source







All Articles