Firebase.firestore.Blob.toBase64() "is Not A Function" ..but Is In The Docs

according to the docs firebase.firestore.Blob.toBase64() is available but apparently I'm calling incorrectly somehow?

adding tiny thumbnails into firestore database (not fire Storage) ..tried to use a normal blob but firestore wants you to use

firebase.firestore.Blob.fromBase64String() ..which works but creates a blob that is unreadable by FileReader() I use firestore.Blob creation but cant figure out how to decode it?

I could just store them as a string but it looks like a blob is ~25% smaller and every byte counts.

var thumb = 'iVBORw0KGgoAA...' //base64 img string
var blob = firebase.firestore.Blob.fromBase64String(thumb); //works
var x = firebase.firestore.Blob.toBase64(blob); //is not a function 

also updated to firebase 6.3.0. but still no joy. thanks in advance



For anybody else who runs into this question, here is the answer directly from firebase-help.

The method firebase.firestore.Blob.toBase64() is a non static Blob method. You will need a firebase.firestore.Blob instance to call it. Also, toBase64() method does not require a parameter. It returns the bytes of its Blob as a Base64-encoded string.

// this will work 
var firestoreBlob = firebase.firestore.Blob.fromBase64String(base64String);
console.log("Firestore to base64 again : "+ firestoreBlob.toBase64() );

Since the method firebase.firestore.Blob.fromBase64String() is a static method, you can invoke it without a blob instance. Please keep in mind that the Firestore Blob type might be different from the required type of your FileReader.