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

Capacitor filesystem readfile file not found from different pages

$
0
0

Hi all.
I have an issue that I dont understand.
In a page of my android app I copy a file to data directory:

const savedFile = await Filesystem.copy({
          from: filename,
          directory: FilesystemDirectory.Cache,
          to: '421429.1629190715467.jpeg',
          toDirectory: FilesystemDirectory.Data
        });

        const contents = await Filesystem.readFile({
          path: '421429.1629190715467.jpeg',
          directory: FilesystemDirectory.Data,
        });

All works fine. I correctly get the content of the file copied.

Now I want to load this file from another page.
The code is quite simple

testReadFile(filename){
      const contents =  Filesystem.readFile({
        path: '421429.1629190715467.jpeg',
        directory: FilesystemDirectory.Data,
      }).then(
        (content) =>{
          console.log('check existing file ' + JSON.stringify(content));
        }
      ).catch(e =>{
        console.log('check existing file ' + e.message);
      });
    }

but I always get “File not found”

What I’m doing wrong?
thanks

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70924

Trending Articles



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