Uploading Files to firebase cloud storage

This topic has been a dead end since we are all still waiting for the Blob support. Not until recently the good Expo dev @wcandillon managed to come up with a work around (see here ā€¦ show some love for the man). The approach worked very well with me on iOS how ever on Android I get this Network request failed error:

and this is how the code looks like:

uploadImage(uri, name, type) {
    return new Promise(async (resolve, reject) => {
      const body = new FormData();
      body.append("picture", {
        uri: uri,
        name,
        type: type
      });
      await fetch(`${cloudFunctionApiUrl}`, {
        method: "POST",
        body,
        headers: {
          Accept: "application/json",
         "Content-Type": "multipart/form-data"
        }
      }).then(async() => {
        console.log("getting download url now ...");
        const url = await firebase.storage().ref(path).getDownloadURL();
        resolve(url);
      }).catch(error => {
        reject(error);
      });
    });
  }

So any clue why this is happening ?

I noticed that overall the networking on Android is a tiny bit less reliable than iOS. And if you are using the 3-tier version of the Cloud function there are some severe quota restrictions applied that might cause such networking error. Iā€™m having the same problem where this error comes up once in a while an Android. I hope that we will find a good solution for this issue.

Blob support has been merged in React Native and hopefully we will be able to use it in Expo soon.

1 Like

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