我已成功下载文件,但无法保存文件。因为我不断收到错误:
[SSZipArchive] Error: You don’t have permission to save the file “fileName” in the folder “Folder_Name”.
[SSZipArchive] Error: You don’t have permission to save the file “fileName” in the folder “__MACOSX”.
任何帮助,将不胜感激!
代码
解压文件函数调用
ZipManager.unzipFile(atPath: filePath, delegate: self)
ZipManager.swift
private static let documentsURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
static func unzipFile(atPath path: String, delegate: SSZipArchiveDelegate)
{
let destFolder = "/Folder_Name"
let destPath = documentsURL.appendingPathComponent(destFolder, isDirectory: true)
let destString = destPath.absoluteString
if ( !FileManager.default.fileExists(atPath: destString) )
{
try! FileManager.default.createDirectory(at: destPath, withIntermediateDirectories: true, attributes: nil)
}
SSZipArchive.unzipFile(atPath: path, toDestination: destString, delegate: delegate)
}