wkh237 / rn-firebase-storage-upload-sample

React Native sample code for upload blob data to Firebase using Firebase SDK with RNFetchBlob.
57 stars 13 forks source link

Download from firebase #6

Open funkysoul opened 7 years ago

funkysoul commented 7 years ago

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!

wkh237 commented 7 years ago

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.

tomershohet commented 7 years ago

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)

wkh237 commented 7 years ago

Thanks for the great information, I think that really helpful !

wkh237 commented 7 years ago

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 👍