I'm trying to download and save a file to the Documents directory. I've done this locally on the client without a problem, but when I use the same path in Alamofire, I get a series of errors.
This is the download component:
func downloadFileAtIndex(index: Int) {
Alamofire.download(.GET, "\(serverURL)/user/\(userID)/project/\(arrayOfProjectIDs[index])/deliverable", { (temporaryURL, response) in
let destinationFolder: String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
let filePath: NSURL = NSURL.fileURLWithPath("\(destinationFolder)/\(arrayOfProjectIDs[index])/myFile.png")!
return filePath
})
}
The response is: The operation couldn’t be completed. (Cocoa error 4.)
The error is: The operation couldn’t be completed. No such file or directory.
I know that the directory doesn't exist yet, but I want to create it, and this doesn't seem to be an issue when saving locally. Any insight would be appreciated.
0 comments:
Post a Comment