我在nodejs服务器上创建了一个路由,该路由发送图像的zip文件。但是不幸的是,每次我向服务器发出请求时,我都可以将zip文件下载到其中,但似乎可以解压缩文件。我收到错误消息“ unarchivable”,错误消息的本地化描述为“操作无法完成。(Zipper.Zipper.ArchiveError错误0。)” nodejs路由与邮递员和我的Android应用完美配合。 / p>
Alamofire:5.0.0-beta.5 迅速:4.2
我发现了这个 Unzipping Error The operation couldn’t be completed. (Zip.ZipError error 1.) between ViewControllers
但是我没道理。我确实尝试在下载过程中使用完成处理程序,但仍然收到相同的错误消息
//快速代码
do {
try FileManager.default.createDirectory(at: self.getDocumentsDirectory().appendingPathComponent("zipServe"), withIntermediateDirectories: true, attributes: nil)
let destination: DownloadRequest.Destination = { _, _ in
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let fileURL = documentsURL.appendingPathComponent("zipServe").appendingPathComponent("pig.zip")
return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
}
AF.download(self.main_url + "imagesAll/shop/", method: HTTPMethod.post, parameters: parameters, headers: headers, to: destination)
.downloadProgress { progress in
print("Download Progress: \(progress.isFinished)")
}
.response { response in
if response.error == nil, let imagePath = response.fileURL {
do {
print(imagePath)
if FileManager.default.fileExists(atPath: imagePath.path) {
print("File exists")
try FileManager().unzip(item: imagePath.absoluteURL, to: self.getDocumentsDirectory().appendingPathComponent("zipServe"))
} else {
print("File not found")
}
} catch let error {
print(error.localizedDescription)
}
}
}
} catch let error as NSError {
print(error.localizedDescription)
}
我应该能够看到zip文件中包含的图像列表。