Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

image fetching fails in SDK 31 Android 5 and 7 #15

Open
jlsilva10 opened this issue Nov 25, 2018 · 4 comments
Open

image fetching fails in SDK 31 Android 5 and 7 #15

jlsilva10 opened this issue Nov 25, 2018 · 4 comments

Comments

@jlsilva10
Copy link

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..

@edvin1983
Copy link

Have same issue here, anyone find a fix?

@jlsilva10
Copy link
Author

@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();
})
}

;)

@limaleandro1999
Copy link

limaleandro1999 commented Nov 29, 2018

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

@Oakyden
Copy link

Oakyden commented Mar 7, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants