Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

Capacitor Where Are My Files On Android?

$
0
0

@aaronksaunders wrote:

I am trying to find the actual paths on device for files when writing them with the Capacitor File Plugin?

The code I am using is directly from the sample, but the documentation is not as detailed as the old cordova-file-plugin.

So what does “/EXTERNAL_STORAGE” translate to on device

  const testFileWrite = async () => {
      try {
        const result = await Filesystem.writeFile({
          path: 'secrets/text.txt',
          data: "This is a test",
          directory: FilesystemDirectory.ExternalStorage,
          encoding: FilesystemEncoding.UTF8
        })
        let stat = await Filesystem.stat({directory: FilesystemDirectory.ExternalStorage, path:'secrets/text.txt'})
        let l = await Filesystem.getUri( {directory: FilesystemDirectory.ExternalStorage, path:'secrets/text.txt'});
        
        console.log('file uri', Capacitor.convertFileSrc(l.uri));
        console.log('stat', stat);
        console.log('Wrote file', result);
      } catch(e) {
        console.error('Unable to write file', e);
      }

      try {
        let ret = await Filesystem.readdir({
          path: 'secrets',
          directory: FilesystemDirectory.ExternalStorage
        });
        console.log(JSON.stringify(ret.files));
      } catch(e) {
        console.error('Unable to read dir', e);
      }
  }

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>