Reading Camera generated file

Using the new Camera component, what’s the right way to read the image that gets saved in the cache folder? The goal is to upload it to a firebase storage bucket and that requires a Blob, Uint8Array, or ArrayBuffer. FileSystem.readAsStringAsync fails for me with

[Error: File 'file:///var/mobile/.....49B2413.jpg' could not be read.]

This error happens to me too.
I guess FileSystem API does not support binary files according to this comment Using Expo.FileSystem to save images to disk, from zip file - #3 by nikki so that the pictures shot by the camera cannot be loaded through FileSystem API.

I found fetch() can load file:// uri but it takes ridiculously long than it should.


It can be read with fetch(), but the contents seems garbled :cry:

1 Like

Hi, I think we are tracking this here but I don’t have a great answer for when it will be fixed.

Same problem here.

Had to use the base64 option mentioned in https://docs.expo.io/versions/latest/sdk/camera.html in order to get the file generated by the Camera.

Sorry I am new to expo so I am sure I am doing something wrong. But I struggle with this as well with reading a video after calling stopRecording(). I can’t get fetch or expo-file-system seem to work. Do you have an example how to use it?

Here is what I am trying to do:

import { readAsStringAsync, EncodingType } from "expo-file-system";
// fsUri passed in by recordAsync() promise
const file = await readAsStringAsync(fsUri, {
      encoding: EncodingType.UTF8,
    });
    console.log(`File read. ${file.length} long`);

This results in an empty string, using base64 encoding crashes on Android without Error and displays the initially mentioned error in iOS.