我使用Alamofire框架從服務器下載映像。我需要進度下載,但我無法得到它。Alamofire progress.fractionCompleted爲null
Alamofire.download(requestForImage, method: .post, parameters: parameters, encoding: URLEncoding.default, headers: nil, to: self.destination)
.downloadProgress{ progress in
self.progressView.progress = progress.fractionCompleted
print(progress.fractionCompleted)
}
.response{ response in
if let headers = response.response?.allHeaderFields as? [String: String]{
print("headers = \(headers)")
// ...
}
if response.error == nil, let imagePath = response.destinationURL?.path {
self.progressView.progress = 1
let image = UIImage(contentsOfFile: imagePath)
print("Image is successfully downloaded!")
self.addNewImageToTheScrollView(img: image)
}
}
}
progress.fractionCompleted = 0.0,progress.totalUnitCount = -1 我發現一個提示上alamofire github上 - 到服務器響應設置 標題( 「內容長度:」 $大小); 但它不會幫助下,有誰知道?)所有其他與這個框架可以作爲應該