I have a React webapp that gets an image, converts it to base64 then sends it over to my REST endpoint.
Trying to save the image directly from frontend to firebase storage
works fine.
When I try to save it from my REST it throws:
[FirebaseStorageError [FirebaseError]: Firebase Storage: String does not match format 'base64': Invalid character found (storage/invalid-format)] {
code: 'storage/invalid-format',
customData: { serverResponse: null }
}
I initialize my storage like this:
const firebaseStorage = () => {
if (firebase.apps.length === 0) {
firebase.initializeApp(config.firebaseConfig);
}
return firebase.storage().ref();
};
And I try to upload to storage like this:
const URI = `images/${uid}/avatar`;
const ref = firebaseStorage().child(URI);
await ref.putString(image64, "data_url");
EDIT
After converting the base64 image to a Blob
and trying to save it to storage via ref.put(blob)
I get the following error:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'byteLength' of undefined