Capacitor Plugins.Camera.getPhoto returns undefined for 'path'

Hey there,

I have a problem.

I just need to select a media for upload

This is what I have

// Image options
const imageData = await Plugins.Camera.getPhoto({
      allowEditing: false,
      source: CameraSource.Photos,
      resultType: CameraResultType.Uri,
    });

on console.log(imageData.path) i get

undefined

I need the imageData ‘path’ for Filesystem.readFile and Filesystem.writeFile

Since the path is undefined, the below shows

File not Found

  const photoInTempStorage = await Filesystem.readFile({
      path: image.path, directory: FilesystemDirectory.Data
  })

Did I miss something? or what is the workaround to resolve this

I appreciate any help.

Check the docs

If using CameraResultType.Uri, the path will contain a full, platform-specific file URL that can be read later using the Filsystem API.

As you are using CameraResultType.DataUrl, then you get image.dataUrl, but

Anyway, image.dataUrl is a data url with all the image data as base64, so you don’t need Filesystem plugin to get the data, it’s all there already.

thanks @jcesarmobile, I actually tested/ used CameraResultType.Uri but path is still undefined

Are you testing on web or as native?

On web there is no path because there is no physical file.

i tested in the Android Emulator