and the code just has no output. Nothing as success or as fail. Just call the readFile and nothing more happens here.
Anyone had the same? Any idea how to solve?
NOT_FOUND_ERR 1 A required file or directory could not be found at the time an operation was processed. For example, a file did not exist but was being opened.
Iām pretty sure the file exists, as I can show the image in my ionc app and I can also read out the file size as you can see in my code. Any other ideas or maybe a working code sample you could provide?
Thanks sid. In the end, the issue was that I couldnāt read/parse image contents via readAsText. I have rewritten my application without the need to parse and read in the image file so that solved my issue. Learned a lot about the file plugin.
Hi @pcr, the problem was that I tried parsing an image by using readAsText. That doesnāt work on images. Iām using avatars.io to upload avatars and the package only need a reference to my filename (not the fully parsed file contents). What I did was simply point to the file path the camera plugin returned and upload that directly.
Does that help? What are you trying to do exactly?
Iām in the final of preparing an article to discribe how to deal with ngCordovaFile functions. I almost solve all problems. I will write some examples how they work.
Also I have some proposals to add/change functions of ngCordova.
Tried your code.
The dowloadFile() part does work or at least it thinks the download is completed.
However when I try to access the downloaded file via checkFile or readFile, it returns error code 5.
$cordovaFile
.downloadFile(source, filePath, true, options)
.then(function(result) {
**// tried checkFile, readFile with filePath, result.fullPath which is /image.png, result.nativeURL which is file://var/mobile/Containers/Data/Application/xxxxx/Library/Caches/image.png They all return error code 5**
$cordovaFile.checkFile(filePath).then(function(result) {
// Success!
}, function(err) {
// An error occurred. Show a message to the user
$timeout(function(){
alert(err.code);
}, 100);
});
}, function(err) {
// An error occurred. Show a message to the user
});
Please tell me the filePath you are using in downloadFile and Iāll help you to solve this issue.
$cordovaFile.checkfile doesnāt work.
In my apps I use window.resolveLocalFileSystemURI(Url, resOnSuccess, resOnError) to check a file exists.
The orignial path for downloading image: filePath = cordova.file.cacheDirectory + āimage.pngā;
or the downloadResult.nativeURL which is
file:///var/mobile/Containers/Data/Application/{app id}/Library/Caches/image.png
Error code: 5
Tried with downloadResult.fullPath which is just /image.png
Error code: 1
I donāt see other pathes from JSON.stringify(downloadResult) other than fullPath or nativeURL
I posted in this thread a solution for working with cordova FileTransfer and file functions together. If you use other filePath structures I canā t help you. Sorry!