How to unzip a big zip file containing one file and get the progress in bytes with swift?

前端 未结 4 2015
无人共我
无人共我 2020-12-30 03:35

I try to unzip a big zip file containing only one item (more than 100MB) and like to show the progress during unzipping.

I found solutions where the progress can be

4条回答
  •  粉色の甜心
    2020-12-30 04:03

    SSZipArchive has not been updated for six years, you need a new choice.

    Zip: Swift framework for zipping and unzipping files.

    let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")!
    let documentsDirectory = FileManager.default.urls(for:.documentDirectory, in: .userDomainMask)[0]
    try Zip.unzipFile(filePath, destination: documentsDirectory, overwrite: true, password: "password", progress: { (progress) -> () in
        print(progress)
    }) // Unzip
    
    let zipFilePath = documentsFolder.appendingPathComponent("archive.zip")
    try Zip.zipFiles([filePath], zipFilePath: zipFilePath, password: "password", progress: { (progress) -> () in
        print(progress)
    }) //Zip
    

提交回复
热议问题