我正在尝试使用以下代码成功下载MP4数据:
private func downloadVideo(cat: String){
DispatchQueue.global(qos: .background).async {
let destination: DownloadRequest.DownloadFileDestination = { _, _ in
var documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let milPath = "VID.mp4"
documentsURL.appendPathComponent(milPath)
return (documentsURL, [.removePreviousFile])
}
Alamofire.download(self.url, to: destination).response { response in
if response.destinationURL != nil {
print(response.destinationURL!)
let path = (response.destinationURL?.absoluteString)!
self.uVid[cat] = path
//self.playVideo(path);
DispatchQueue.main.async {
let uim = self.uBlur[cat]
self.disappearView(im : uim!)
}
}
}
}
}
但是,我无法附加服务器所需的自定义标头,同时为我提供了正确的mp4数据。有人可以构建一个示例/建议,告诉我如何在传入自定义标题时调用Alamofire.download()函数吗?
答案 0 :(得分:1)
我设法找到了这个问题的解决方案。
简单地将标题数组添加到self.ur,到:destination
之间