Ionic 4: file.resolveFilesystemUrl is not a function

Hi,
I am having an issue with the File plugin in working with ionic.
The error is:
ERROR TypeError: this.file.resolveLocalFilesystemUrl is not a function
plugin Version is 6.0.2 and it’s present when I run cordova plugin ls

My code looks like this:

download(num: number) {
    const d = new Date();
    const n = d.getTime();
    const newFileName = n + '.jpg';

    const externalStoragePath: string = this.file.dataDirectory;
    console.log(externalStoragePath);
    // externalStoragePath is always undefined...


    this.file.resolveLocalFilesystemUrl('file:///' + this.slides[num]).then((entry: any) => {
      this.file.resolveLocalFilesystemUrl(externalStoragePath).then((dirEntry: any) => {
        entry.copy(dirEntry, newFileName);
      }).catch((error) => {
        console.log('dirEntryerror: ' + error);
      });
    });
  }

What I already tried:

  • looking in the plugin code itself, the function is there;
  • remove and reinstall the plugin
  • when I type in the beginning of the function, my IDE suggests it and there is no Error, also in compiling…

I hope you can help me :slight_smile:

On which Device are you testing?

on Android and on Browser, same behaviour :confused: