【发布时间】:2018-01-08 20:44:06
【问题描述】:
我已成功下载文件,但无法保存文件。因为我不断收到错误:
[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)
}
【问题讨论】:
-
您不应该将
destPath传递给SSZipArchive.unzipFile函数吗? -
@Kymer 不接受
String,所以我不能输入URL -
嗯...
destString那么?也许您应该稍微清理一下该功能。例如,您似乎没有使用path参数。 -
@Kymer 不确定您的意思。我在`SSZipArchive.unzipFile(atPath:path,toDestination:destString,delegate:delegate)`中使用
path` -
您是否开启了应用沙盒功能?
标签: ios swift ssziparchive