But when I use $cordovaFile.checkFile(‘cdvfile://localhost/persistent/myFolder/newFile.jpg’).then(…), it always returns an error. It seems like it doesn’t find the file.
Am I doing it correctly? How do we check for a file using ng-cordova? The docs are sparse but pretty self-explanatory so I’m not sure what else to do. Google Groups on Phonegap don’t mention anything in this light. I’ve been testing different approaches and file/path referencing but nothing seemed to work. Any help would be much appreciated.
I don’t think it is safe to user cdvfile:// …
Are you building on android or ios ? Try cordova recommended paths prefix like cordova.file.dataDirectory http://plugins.cordova.io/#/package/org.apache.cordova.file
See Where to store files section
In case of android I have had troubles with cordova.file.documentsDirectory. Try cordova.file.externalRootDirectory
make sure you download your files in the same path
I use the last example. But after creating a file (with the same url) a checkfile always returns a error 1 (NOEACC). So I can write to a file but cannot check it?.