rn-firebase-storage-upload-sample
rn-firebase-storage-upload-sample copied to clipboard
Download from firebase
hey @wkh237 what would be the best way to download an image stored in firebase when uploaded as a blob?
This is how I upload to storage:
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest; window.Blob = Blob; ... uploadProfilePicture(file){ var that = this; const rnfbURI = RNFetchBlob.wrap(file); Blob .build(rnfbURI, { type : 'image/jpeg;'}) .then((blob) => { console.log("userID from upload: " + userID); console.log("POSTKEY from upload: " + newPostKey); this.fb.storage() .ref('photos/' + userID) .child('profile_image.jpg') .put(blob, { contentType : 'image/jpeg' }) .then((snapshot) => { blob.close() done() }) }) } ....
and is this how I'm supposed to download an image?
... this.fb.storage().ref('photos').child("test.jpg").getDownloadURL().then((url) => { RNFetchBlob .config({ fileCache : true, appendExt : 'jpg' }) .fetch('GET', url) .then((resp) => { console.log(resp); }) }) ...
the above returns nothing, using the default firebase implementation also results nothing
Kind of lost here, as soon as I hook up your library with verbose on I see that my request to grab the downloadURL is being handled by the XMLHttpRequest polyfill.
Many thanks for your help mate!
Hi @funkysoul , I think this may related to Firebase SDK's version, and we are still try to find where's the problem. You may try use Firebase 3.4.1 and see if it works.
Most likely that it will work for you on 3.5.3 as well (That's the newest one that will be working for you)
Thanks for the great information, I think that really helpful !
There's a new release of react-native-fetch-blob
, please try upgrade the package to 0.10.1-beta.1
and see if that fix the issue 👍