Zip
Zip copied to clipboard
Unable to zip file from URL
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 have you solved the problem?