title: Ionic 3 Native : File : {code: 5, message: "ENCODING_ERR"}
body: <p>I'm using the <a href="https://ionicframework.com/docs/native/file#checkFile" rel="noreferrer">checkFile function from File API plugin</a> in Ionic 3 to check if a file exists locally. The Promise rejects with the following error :</p>
  
  <blockquote>
    <p>FileError {code: 5, message: "ENCODING_ERR"}</p>
  </blockquote>
  
  <p>From what I see on the <a href="https://developer.mozilla.org/en/docs/Web/API/FileError" rel="noreferrer">Mozilla Docs of the File API</a>, 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 <code>baseDirectory</code> is set to <code>file:///data/user/0/ch.protectator.fehpedia/files/</code>) :</p>
  
  <pre><code>let baseDirectory = this.file.dataDirectory;
  let fileToCheck = "File:Icon Portrait Abel.png";
  
  let promise = this.file.checkFile(this.file.dataDirectory, fileName).then(bool =&gt; {
      // Things
  }, reason =&gt; {
      console.error(reason);
  });
  </code></pre>
  
  <p>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 <strong>the image displays</strong>.</p>
  
  <p>In the HTML template, I later use :</p>
  
  <pre><code>&lt;img [src]="imgUrl"&gt;
  </code></pre>
  
  <p>where <code>imgUrl</code> is set using :</p>
  
  <pre><code>this.imgUrl = this.file.dataDirectory + '/' + "File:Icon Portrait Abel.png";
  </code></pre>
  
  <p>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 <code>checkFile</code> be used in a different way ? Also, a more precise cause of failure would help, but all I got is <code>ENCODING_ERR</code>, I don't know what actual part of the URL seems malformed.</p>