4

我需要发送一个带有参数的文件并跟踪上传进度。方法

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)
     }

无法设置参数

是否可以发送带有参数的文件并跟踪上传进度?

4

2 回答 2

2

您必须使用.uploadProgress而不是.progress

于 2016-09-12T14:27:33.137 回答
0

使用这种方式

    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)

    })
于 2017-02-01T09:52:18.727 回答