I have a code who upload a an image to firebase storage , its working great but i want to download the image locally in a folder in react native app ? is it possible ?
async function uploadImageAsync(uri) {
const UID = Firebase.auth().currentUser.uid;
// Why are we using XMLHttpRequest? See:
// https://github.com/expo/expo/issues/2402#issuecomment-443726662
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);
});
const ref = Firebase
.storage()
.ref('users/' + UID)
.child('profile');
const snapshot = await ref.put(blob);
// We're done with the blob, close and release it
blob.close();
return await snapshot.ref.getDownloadURL();
}