Downloading Firebase Storage Files Device Issue <p>I am trying to download a word document from Firebase storage. On the simulator everything is working as expected. Yet on my device, I get the following error:</p> <blockquote> <p>Optional(Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response." UserInfo={object=Bulletin/26 October 2016.docx, bucket=southam-college-app.appspot.com, NSLocalizedDescription=An unknown error occurred, please check the server response., ResponseErrorDomain=NSCocoaErrorDomain, NSFilePath=/tmp/bulletin, NSUnderlyingError=0x1702590b0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}, ResponseErrorCode=513})</p> </blockquote> <p>Other posts I have been looking at do not seem to give me a working answer, and all I know is that there is an issue with file permissions, even though I am using the recommended directory (tmp).</p> <p>This is the code for downloading the file</p> <pre><code> let Ref_Bulletin = Bulletin.referenceForURL("gs://southam-college-app.appspot.com/Bulletin/\(Today.stringFromDate(NSDate())).docx") // Create local filesystem URL let localURL: NSURL! = NSURL(string: "file:///tmp/bulletin/today.docx") // Download to the local filesystem let downloadTask = Ref_Bulletin.writeToFile(localURL) { (URL, error) -&gt; Void in if (error != nil) { print(error.debugDescription) // Uh-oh, an error occurred! } else { print("Working As Expected") self.Web_View.loadRequest(NSURLRequest(URL: localURL)) } </code></pre> <p>So what is causing this problem and how do I fix it?</p> <p><strong>Update:</strong></p> <p>So I tried to create the directory but I am being told that I don't have permission even though the documentation says I can write to the tmp.</p> <blockquote> <p>Unable to create directory Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “today.docx” in the folder “bulltin”." UserInfo={NSFilePath=/tmp/bulltin/today.docx, NSUnderlyingError=0x1702498a0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}</p> </blockquote> <p>This is the code for creating the directory:</p> <pre><code> do { try NSFileManager.defaultManager().createDirectoryAtPath(localURL.path!, withIntermediateDirectories: true, attributes: nil) } catch let error as NSError { NSLog("Unable to create directory \(error.debugDescription)") } </code></pre>