Ionic Capacitor Filesystem fileExist

I have some pictures stored on /src/assets/img/.
Now I want to check if an image exists. If yes I want to display it, else I want to display a placeholder img.

I tried

async checkFile(strPath: string)
    {
        let contents = await Filesystem.readFile({
            path: strPath,
            directory: FilesystemDirectory.Data,
            encoding: FilesystemEncoding.UTF8
        });
        console.log(contents);
    }
checkFile('/assets/img/kategorien/image.jpg).then(function ...

But it doesn’t work. The file is not found. How do I have to set the path/directory for it to work?

1 Like