I'm seeing a lot of talk about uploading to Firebase storage from React Native, but all seem to be how to get around the fact that React Native doesn't support Blobs or Files. But Firebase has a putString method for uploading base64 encoded files.
Why does this code, for example, work in a browser but not in React Native:
var base64String = "iVBORw0KGgoAAAA...";
firebase
.storage()
.ref()
.child(`test/test.png`)
.putString(base64String, 'base64')
.then(function(snapshot) {
console.log('Uploaded a base64 string!');
})
.catch(function(err) {
console.log('Problems', err);
});
No errors are given in React Native, but no file arrive in Firebase. What gives?
putString()is thennable, it probably also defines acatch()that is called when there are errors:.putString(base64String, 'base64') .then(function(snapshot) { console.log('Uploaded a base64 string!'); }).catch(function(error) { console.error(error); });- Frank van Puffelen