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

Response.blob() is not working

Open maxweb4u opened this issue 6 years ago • 5 comments

When I implemented this code, I got this mistake:

[TypeError: response.blob is not a function. (In 'response.blob()', 'response.blob' is undefined)]

When I debug it, if I print response, it prints response object after mistake. I'm sure that await/async is in the code.

Any get this error ?

maxweb4u avatar Aug 01 '18 19:08 maxweb4u

I did but I solved it by updating expo to SDK28 and updating react-native to 0.55.4 (which expo SDK28 is based on).

alyssaong1 avatar Sep 13 '18 02:09 alyssaong1

@maxweb4u Hi, I am facing the same issue with expo 31.0.2. Did you managed to solve it somehow?

dev-anees avatar Nov 25 '18 18:11 dev-anees

@anees715 yes, I have fixed it, it's working with 25.0.0

maxweb4u avatar Nov 26 '18 10:11 maxweb4u

@anees715 I am also facing the same issue. It was working with expo 27.0.0. After upgrading to 31.0.2 it stopped working. When I upload an image to firebase storage it is uploading a blank image because of this blob issue. @maxweb4u How do you downgrade your expo? When I create a new expo project it automatically uses the latest version.

jlsilva10 avatar Nov 26 '18 17:11 jlsilva10

@anees715 Hey I have found the solution. Here is a function to get the blob from an uri: 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(); }) }

After calling this function you'll get the blob and everything should be fine now ;)

jlsilva10 avatar Nov 27 '18 10:11 jlsilva10