Filesystem.stat() fails to find entry

I am trying to get the creation date from a picture using @capacitor/filesystem and its stat() method

However the call to stat() fails at :

ERROR Error: Uncaught (in promise): Error: Entry does not exist.
Error: Entry does not exist.
    at web.js:327:19

I am debugging this on my computer right now (web). Haven’t tested on device yet.

The code fails both when taking a picture with the camera and when selecting a pic from the local Documents folder.

My code:

import { Filesystem, Directory } from '@capacitor/filesystem'
let image = await this.takePicture()
                      
let fileStats = await Filesystem.stat(
  {
    path : image.webPath,
    directory: Directory.Documents,
  })
console.log(fileStats);

where takePicure() is

const image = await Camera.getPhoto({
    quality: 40,
    allowEditing: false,
    source: CameraSource.Camera,
    resultType: CameraResultType.Uri
  });
  
  image["base64"] = await convertToBase64(image.webPath)
  image["exif"] = await getExif(image.webPath)
 
  return image

The image object is

base64: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvA
exif: "{\n    \"BitDepth\": 8,\n    \"ColorType\": \"RGB with Alpha\",\n    \"Compression\": \"Deflate/Inflate\",\n    \"Filter\": \"Adaptive\",\n    \"ImageHeight\": 590,\n    \"ImageWidth\": 752,\n    \"Interlace\": \"Noninterlaced\"\n}"
format: "png"
saved: false
webPath: "blob:http://localhost:8100/91951516-56d7-4917-841d-790fe39b4cd1"

I must be missing something very obvious. Any help would be much appreciated

update 1 : also tried with no success:

let fileStats = await Filesystem.stat(
  {
    path : image.webPath
   })

Still stuck with this. Any ideas?

I don’t have a good answer for you, but some potential areas for you to investigate are:

  • Do you have permissions set to access the area you’re trying to stat? That bit me one time, I seem to recall.
  • Have you tried with/without file:// in front? It is different for android and ios. Note that it means there would be 3 slashes in a row, like file:///your/path/here
  • If you run it from android studio you can use a file explorer to dig into the emulator’s file system to understand the structure it has.

Thanks for your suggestions.

I do seem to have permissions to access the files though.

However I haven’t even tried android or ios yet. It just doesn’t even work in my web browser when running ionic serve… or it is not supposed to work in browser? Am I missing something?