Check media file exists

Hello
I’m using ionic v3.

I download and save an audio file

this.file.writeFile(this.file.externalDataDirectory, fileName, xhr.response, { replace: true })
                .then(success => {
                  audio = this.media.create(success.nativeURL.replace(/file:\/\//g, ''));
                  audio.play();
                }, function (error) {
                  console.log("KO");
                });
            }

But when check if the file exsits I get only error status code 5, ENCODING_ERR:

let filePath = this.file.externalDataDirectory + fileName;
    let path = this.file.externalDataDirectory.replace(/file:\/\//g, '');

    console.log(path + fileName);
    this.file.resolveLocalFilesystemUrl(path + fileName)
      .then(res => {
 console.log("OK"
      }).catch(err => {
console.log("KO")}

Where I’m wrong?
I expect an NOT_FOUND_ERR, not and ENCODING_ERR

Ok, problem solved.

In file native plugin there’s no need to trim “file://”
So I removed this line

let path = this.file.externalDataDirectory.replace(/file:\/\//g, '');