Error: You don’t have permission to save the file in the folder

Viewed 13697

I've successfully downloaded the file but I am unable to save the file. Because I keep getting the error(s):

[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”.

Any help would be appreciated!

Code

Unzip file function call

 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)
    }
1 Answers
Related