Hello,
I'm trying to upload images in base64 to the firebase, but I'm getting the following error. I tried to follow the Firebase tutorial on the official website and one found here on the stack itself, but I still get the same error.
{code: "storage / invalid-format", message: "Firebase Storage: String does not match format 'base64': Invalid character found ", serverResponse: null, name: "FirebaseError"}
$scope.upload = function (dataUrl, name) {
var image = dataUrl;
uploadTask = firebase.storage().ref('profileImg', loggedUserSrvc.getUser().uid).child('profileImg').putString(image, 'base64', {contentType:'image/jpg'});
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed'
function(snapshot) {
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
switch (snapshot.state) {
case firebase.storage.TaskState.PAUSED: // or 'paused'
console.log('Upload is paused');
break;
case firebase.storage.TaskState.RUNNING: // or 'running'
console.log('Upload is running');
break;
}
}, function(error) {
console.log(error);
}, function() {
// Upload completed successfully, now we can get the download URL
var downloadURL = uploadTask.snapshot.downloadURL;
});
}
<div class="card">
<button ng-click="upload(croppedDataUrl, picFile.name)" class="button button-balanced button-block">
Salvar
</button>
</div>