2

I am trying to download zip file and extract zip file and save to local directory. When user come back and check unzipped file is available in local directory.

Here i am using alamofire for downloading zip file:

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)
        }
    }
}
Thomas Zoechling
  • 34,177
  • 3
  • 81
  • 112
PvUIDev
  • 95
  • 1
  • 9
  • 38

1 Answers1

0

you can use this repo to unzip your file : https://github.com/weichsel/ZIPFoundation

Shahzaib Qureshi
  • 989
  • 8
  • 13