【问题标题】:How to download zip file from server url and extract zip file save to local directory in ios swift?如何从服务器 url 下载 zip 文件并将 zip 文件解压缩到 ios swift 中的本地目录?
【发布时间】:2020-02-07 10:56:51
【问题描述】:

我正在尝试下载 zip 文件并提取 zip 文件并保存到本地目录。当用户返回并检查本地目录中是否有解压缩文件时。

这里我使用 alamofire 下载 zip 文件:

func zipFileApiCall() {
    let aString = fullFormKey
    let result = String((aString?.dropFirst(6))!)
    let s = String(result.dropLast(10))
    print("newFormKey", s )
    let vKey = self.convap(text: s)
    let newString = vKey.replacingOccurrences(of: ":", with: "/", options: .literal, range: nil)
    print("full form key string /", newString )
    let v = "https://storage.url.com"+newString+"/assets.zip"
    let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)
    AF.request(v).validate().responseJSON { response in
        debugPrint(response)
        switch response.result {
        case .success:
            print("save form zip", response.value ?? "")
        case .failure(let error):
            print("Error:", error)
        }
    }
}

【问题讨论】:

标签: ios swift zip alamofire gzip


【解决方案1】:

你可以使用这个 repo 来解压你的文件: https://github.com/weichsel/ZIPFoundation

【讨论】:

  • 如何先下载zip文件?
  • 虽然这个 repo 可能解决了这个问题,但最好作为评论。请查看How to Answer
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-03
  • 2021-03-07
  • 1970-01-01
  • 2016-12-28
  • 1970-01-01
  • 2017-05-13
  • 1970-01-01
相关资源
最近更新 更多