firebase-storage-upload-example icon indicating copy to clipboard operation
firebase-storage-upload-example copied to clipboard

image fetching fails in SDK 31 Android 5 and 7

Open jlsilva10 opened this issue 6 years ago • 4 comments

Hi there, I was trying this example using Expo SDK 31 and Android 5 and 7 (because SDK 31 only works with 5+) But there is an issue here: const response = await fetch(uri);

It will say: [TypeError: Network request failed]

It was working when I was using SDK 27 and Android 4 Now that I upgraded Expo I came across this issue..

jlsilva10 avatar Nov 25 '18 04:11 jlsilva10

Have same issue here, anyone find a fix?

edvin1983 avatar Nov 27 '18 16:11 edvin1983

@edvin1983 I already have a fix. You can use this function to get the blob: function urlToBlob(url) { return new Promise((resolve, reject) => { var xhr = new XMLHttpRequest(); xhr.onerror = reject; xhr.onreadystatechange = () => { if (xhr.readyState === 4) { resolve(xhr.response); } }; xhr.open('GET', url); xhr.responseType = 'blob'; // convert type xhr.send(); }) }

;)

jlsilva10 avatar Nov 27 '18 17:11 jlsilva10

@jlsilva10 it's worked for me, ty, u saved my life!

limaleandro1999 avatar Nov 29 '18 20:11 limaleandro1999

Yes, THANKYOU!

I was using Expo sdk 32 and there is literally nothing about getting an image to firebase storage in expo. It seemed impossible. However, your xhr example and the fantastic explanation around it in the github comment has solved everything. Well done.

Oakyden avatar Mar 07 '19 11:03 Oakyden