我需要发送一个带有参数和跟踪上传进度的文件。方法
Alamofire.request(.POST, "http://httpbin.org/post", parameters: parameters, encoding: .JSON)不跟踪上传进度。方法
Alamofire.upload(.POST, "http://httpbin.org/post", file: fileURL)
.progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in
println(totalBytesWritten)
}
.responseJSON { (request, response, JSON, error) in
println(JSON)
}无法设置参数
是否可以发送带有参数并跟踪上传进度的文件?
发布于 2016-09-12 22:27:33
您必须使用.uploadProgress而不是.progress。
发布于 2017-02-01 17:52:19
使用这种方式
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)
})https://stackoverflow.com/questions/26500964
复制相似问题