I'm using the checkFile function from File API plugin in Ionic 3 to check if a file exists locally. The Promise rejects with the following error :
FileError {code: 5, message: "ENCODING_ERR"}
From what I see on the Mozilla Docs of the File API, the problem is that "The URL is malformed." However, I don't see how is the URL malformed. Here is the relevant code showing how I'm calling the function plus the actual values of involved variables (The value of baseDirectory
is set to file:///data/user/0/ch.protectator.fehpedia/files/
) :
let baseDirectory = this.file.dataDirectory;
let fileToCheck = "File:Icon Portrait Abel.png";
let promise = this.file.checkFile(this.file.dataDirectory, fileName).then(bool => {
// Things
}, reason => {
console.error(reason);
});
And that's the Promise that fails. What's strange about that case is that I actually tried to display that image later in the code, ignoring if it has been found by File.checkFile, and the image displays.
In the HTML template, I later use :
<img [src]="imgUrl">
where imgUrl
is set using :
this.imgUrl = this.file.dataDirectory + '/' + "File:Icon Portrait Abel.png";
So the image exists and displays correctly when called by the WebView, but the Native File plugin tells me the URL is malformed, even to me it seems to be exactly the same URL. That's where I'm stuck, I don't know what to change for the code to work. Should checkFile
be used in a different way ? Also, a more precise cause of failure would help, but all I got is ENCODING_ERR
, I don't know what actual part of the URL seems malformed.