How to read gallery image bytes data in expo project?

62 views Asked by At

I am making an app which takes backup of photos in device. For that, I need to get the image bytes data.

I can get the uri of a gallery item using expo-media-library -

MediaLibrary.getAssetsAsync({
      first: 100,
      sortBy: "creationTime",
})

But the assets returned by this do not have the image bytes field. However, they have a field uri which I used to retrieve the image data with expo-file-system.

FileSystem.readAsStringAsync(uri, {
      encoding: FileSystem.EncodingType.Base64,
})

This is giving me error

Error: Unsupported URI scheme for 'ph://6ED12572-E99F-47DD-8E71-BAFA7510E71D'

Is there any way I can read image bytes or convert this ph:/// uri to a file:/// uri?

0

There are 0 answers