Zip icon indicating copy to clipboard operation
Zip copied to clipboard

Unable to zip file from URL

Open Zulqurn opened this issue 1 year ago • 1 comments

Hi, I am trying to zip file which I have accessed via UIDocumentPickerViewController and saving it in the same directory with source and destination url: file:///private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/Downloads/ and I am getting this error: The operation couldn’t be completed. (Zip.ZipError error 2.) with description Error: Failed to zip file.

Here is the code: func zip(url: URL) -> URL? { do { let tokens = url.lastPathComponent.split(separator: ".") let firstToken = "\(tokens.first ?? "")" let zipFilePathURL = try Zip.quickZipFiles([url.deletingLastPathComponent()], fileName: firstToken) return zipFilePathURL } catch let error { logger.error("\(#function) Error: \(error.localizedDescription)") } return nil }

I tried to zip a .pdf file when I got this error. I will be glad if you can help me out here. Thanks in advance.

Zulqurn avatar Dec 08 '22 02:12 Zulqurn

@Zulqurn have you solved the problem?

Nassonov avatar Jun 05 '23 11:06 Nassonov