ios - Saving a file to .DocumentDirectory using Alamofire -
i'm trying download , save file documents directory. i've done locally on client without problem, when use same path in alamofire, series of errors.
this 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] string let filepath: nsurl = nsurl.fileurlwithpath("\(destinationfolder)/\(arrayofprojectids[index])/myfile.png")! return filepath }) }
the response is: the operation couldn’t completed. (cocoa error 4.)
the error is: the operation couldn’t completed. no such file or directory.
i know directory doesn't exist yet, want create it, , doesn't seem issue when saving locally. insight appreciated.
your directory not exist. need create nsfilemanager
. perform download.
Comments
Post a Comment