Expo with Firebase Cloud Storage

It is mentioned in the docs that Expo has no support of Firebase Cloud Storage yet due to the unavailability of Blobs. So I find myself left with no choice but to resort to AWS3 to overcome this. But before I go on about doing so I wanted to check if there is a plan to support Firebase Cloud Storage in the coming update so I can wait for it instead ?

Hey @ahmedsamyabdelhay,

The Blob Support PR was just recently added to RN 0.54. Based on the assumption that 0.54 gets released when expected (Early March) and the PR doesn’t get reverted, Expo will have preliminary Blob support with SDK27 which is targeted for a late March release.

With that said, a fellow Expo dev @wcandillon has shared a method that utilizes fetch to send a post request to a firebase cloud function that allows you to upload to cloud storage that you could use now. Here is his blog post: Uploading Images to Firebase with Expo | by William Candillon | Medium If you find it helpful, be sure to show him some love. One thing to be aware of is Firebase Cloud Fxs have a request body limit of 10MB so if you’re uploading videos, you’ll likely have to use alternate means such as Google’s App Engine.

Cheers,

Adam

2 Likes

We are using this way also while waiting for SDK27

Hey adamjnav, I followed the man’s guide and I showed him love for his help although the guide was not quite well constructed … and the code is copied without explaining what lines that needs to be changed. Thats is why I am stuck in this issue here.

Here is the code from my app client side:

const uri = result.uri;
const name = uri.split("/")[uri.split("/").length - 1];
    const type = name.split(".")[1];
    const body = new FormData();
    body.append("picture", {
      uri: uri,
      name,
      type: type
    });
    await fetch(`${linkToCloudFunction}`, {
      method: "POST",
      body,
      headers: {
        Accept: "application/json",
       "Content-Type": "multipart/form-data"
      }
    });

I use ImagePicker and the above piece of code is executed upon getting the result (result.uri).
Once executed, I get a network request failed error on Android.

It is helpful if you post the actual error message as well.

Is it possible that your content is exceeding that mentioned 10MB limit?

The image is 1.72 mb and here is a screen shot of the error

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.

this might be useful for you: https://github.com/expo/firebase-storage-upload-example