Maybe I'm missing something but
let encoded = btoa(await myblob.text().then(btoa);
... is all you need to do to encode a Blob
's data to base64. See Blob.text()
and btoa()
.
Or if you want the whole thing as a promise:
let encode = myblob.text().then(btoa);
PS: To decode back to a Blob: new Blob([atob(encoded)])