Capacitor writeFile, how to save a video?

Hi guys,

I am trying to save a video file. I get the blob data from recordRTC api, then I create a File:

const f = new File([blob], `video_${Date.now()}.mp4`, {
      type: 'video/mp4'
    });

    this.fileWrite(f);

Then I try to write the file like this:

 fileWrite(file: File) {
    try {
      this.getBase64(file, (result) => {
        Filesystem.writeFile({
          path: 'media/videoReader.mp4',
          data: result,
          directory: FilesystemDirectory.Documents
        });
      });

    } catch (e) {
      console.error('Unable to write file', e);
    }
  }

But I can not save it since it asks for a string. I have tried this two functions to convert it to base64 first:

 getBase64(file, callback) {
    const reader = new FileReader();
    reader.onload = () => {
        callback(reader.result);
    };
    reader.readAsDataURL(file);
  }

  getBase64New(file) {
    return new Promise((resolve, reject) => {
      const reader = new FileReader();
      reader.readAsDataURL(file);
      reader.onload = () => resolve(reader.result);
      reader.onerror = error => reject(error);
    });
  }

But no luck. Any idea?

Thanks a lot.

Am also trying to figure out if Capacitor’s Filesystem can handle video and other such blob files by converting to and from base64. Or whether falling back to cordova-plugin-file would be necessary for these purposes?

Anyone know?

Also looking for this solution.