0
Hello,
I am trying to upload Base64 images to firebase, but am 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 keep getting 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>