'Convert Image to blob in Expo React Native
I am trying to upload images to Firebase storage from my expo application. Then I need to convert the URI to the blob that will be sent to firebase. I have tried both code samples below for the conversion but none of them is working and other answers on SO aren't specific to Expo apps.
What I've tried
const blob = await new Promise( ( resolve, reject ) => {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
resolve( xhr.response );
};
xhr.onerror = function ( e ) {
console.log( e );
reject( new TypeError( "Network request failed" ) );
};
xhr.responseType = "blob";
xhr.open( "GET", uri, true );
xhr.send( null );
} );
I've also tried
const response = await fetch( uri );
const blob = await response.blob();
Sample error code
childPath.split is not a function. (In 'childPath.split('/')', 'childPath.split' is undefined)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
