Reputation: 16825
In javascript I am creating a blob from an array like so:
const a = new Blob([[1,2,3]]);
when I try to save this blob like:
this.afs.collection('events').doc(event.getID()).set({data: new Blob([[1,2,3]])}).then((some) => {
debugger;
})
I get an error:
DocumentReference.set() called with invalid data. Unsupported field value: a custom Blob object (found in field data)
What should I do to save a blob via JS to Firestore?
Upvotes: 2
Views: 3595
Reputation: 3082
Your blob needs to be of type firebase.firestore.Blob
. Then using static fromUint8Array
:
var firebase = require('firebase');
var app = firebase.initializeApp({ ... });
...
const blob = firebase.firestore.Blob.fromUint8Array(new Uint8Array([1,2,3]));
Upvotes: 5