How to check if Filesystem functions are working?

I am trying to store downloaded mp3 audio files into storage somewhere so that I can play them with the html <audio> tag.

I have been trying to store the files in FilesystemDirectory.Data using Capacitor’s Filesystem API. I don’t get an error when I do the copying, which I assume means the copies are working. However, I’m unable to play them, which makes me wonder if the copies are working.

How can I browser the FilesystemDirectory.Data directory to confirm that the copying is working? I’ve used Android Studio’s Device File Explorer, but have found no files in /data/data/…/etc., which makes me think the copying is failing.

Any other ideas? thanks.

Vic

P.S. Here is my code to store the files:

export const fileWrite = (fname: string, data: string) => {
  try {
    Filesystem.writeFile({
      path: fname,
      data,
      directory: FilesystemDirectory.Data,
      encoding: FilesystemEncoding.UTF8
    });
  } catch (e) {
    console.error('Unable to write file', e);
  }
};

I figured out how to do this. If you are copying files to the FilesystemDirectory.Data area, then in Android Studio you can see them by doing this:

  • Connect your device to your computer
  • Open View -> Tool Windows -> Device File Explorer
  • Go to data / data / <yourappid> / files

You can even download them to your computer and view them there, if you want.

Hope this helps someone.

1 Like