Skip to content
Advertisement

Expo Camera Photo Upload To Firebase Storage is undefined – React Native

I am using import { Camera } from 'expo-camera'; to take pictures. The taken picture is stored in the devicecache. so far so good.

Now I am trying to upload this taken images to Google Firebase Storage using import { getStorage, ref, uploadBytes } from "firebase/storage";

The return of doing a photo is:

JavaScript

Now I try to upload this like that:

JavaScript

After a little delay, there is a file created in firebase/storage . I can open this file by an texteditor. the file includes the text undefined

The assumption is that the uri that i hand over is not the right solution. However, I’m too new to development and can’t find any help for react native. do you have an idea, a link or an example? Do I first have to convert the file to a blob or base64 and if so, how?

Advertisement

Answer

Everytime after I post a Question, I do find the solution.

I blob the file like that:

JavaScript

and uploaded this result like this:

JavaScript

Here is the full function for my solution:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement