1

After using expo's ImagePicker and saving the image in the local cache, I am trying to save the image to firebase storage (or its new name, Cloud Storage for Firebase).

The relevant code is:

base64String =
  FileSystem.readAsStringAsync(photoUri,
  { encoding: FileSystem.EncodingTypes.Base64 });

and then

ref.putString(base64String,'base64',
  { contentType: 'image/jpeg' })

However, something is wrong with the image that I save to firestore, and I cannot view it (either directly from the firestore console or my code).

Am I doing anything wrong?

Yossi
  • 5,577
  • 7
  • 41
  • 76

1 Answers1

0

the problem here is the upload funcition that uses the standard atob and btob functions. that are missing in react-native/expo while expo uses the web js implementation which thinks it's running on the browser.

solution works from here: React Native atob() / btoa() not working without remote JS debugging

this will add global btoa, atob funcitions add it to App.js and there you go..

import {decode, encode} from 'base-64'

if (!global.btoa) {
    global.btoa = encode;
}

if (!global.atob) {
    global.atob = decode;
}