1const blobToBase64 = (blob) => {
2 return new Promise((resolve) => {
3 const reader = new FileReader();
4 reader.readAsDataURL(blob);
5 reader.onloadend = function () {
6 resolve(reader.result);
7 };
8 });
9};
10
11(async () => {
12 const b64 = await blobToBase64(blob);
13 const jsonString = JSON.stringify({blob: b64});
14 console.log(jsonString);
15})();
16
1const parsed = JSON.parse(jsonString);
2const blob = await fetch(parsed.blob).then(res => res.blob());
3console.log(blob);
4