ios - NSPOSIXErrorDomain wher download file -


i have next code download file url. i'm getting next error:

failed error: error domain=nscocoaerrordomain code=516 "“cfnetworkdownload_85dvq4.tmp” couldn’t moved “documents” because item same name exists." userinfo={nssourcefilepatherrorkey=/users/otani/library/developer/coresimulator/devices/8babc203-7fd9-4f03-bf0d-d660dd29ccde/data/containers/data/application/09c714d3-f185-4289-91db-13b21557b784/tmp/cfnetworkdownload_85dvq4.tmp, nsuserstringvariant=( move ), nsdestinationfilepath=/users/otani/library/developer/coresimulator/devices/8babc203-7fd9-4f03-bf0d-d660dd29ccde/data/containers/data/application/09c714d3-f185-4289-91db-13b21557b784/documents/temp.llg, nsfilepath=/users/otani/library/developer/coresimulator/devices/8babc203-7fd9-4f03-bf0d-d660dd29ccde/data/containers/data/application/09c714d3-f185-4289-91db-13b21557b784/tmp/cfnetworkdownload_85dvq4.tmp, nsunderlyingerror=0x7fea5a53a9a0 {error domain=nsposixerrordomain code=17 "file exists"}}

code downloading file below:

func downloadfile(let url: string!){         self.downloadhud()         alamofire.download(.get, url) { temporaryurl, response in             let documentsurl =  nsfilemanager.defaultmanager().urlsfordirectory(.documentdirectory, indomains: .userdomainmask).first!             let fullpath = documentsurl.urlbyappendingpathcomponent(misc.pathtosavefile)             if (nsfilemanager.defaultmanager().fileexistsatpath(fullpath.absolutestring)){                    try! nsfilemanager.defaultmanager().removeitematurl(fullpath)             }             return fullpath          }         .progress { bytesread, totalbytesread, totalbytesexpectedtoread in                 dispatch_async(dispatch_get_main_queue()) {                     self.hud.progress = float(totalbytesread) / float(totalbytesexpectedtoread)                     print("total bytes read on main queue: \(totalbytesread)")             }         }         .response { _, _, _, error in                 if let error = error {                     print("failed error: \(error)")                 } else {                     print("downloaded file successfully")                     self.hidehud()                 }         }      } 

error gets on line

print("failed error: \(error)") 

solution rewrite deleting destination file .


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -