Answers for "javascript stringify blob"

0

javascript stringify blob

const blobToBase64 = (blob) => {
  return new Promise((resolve) => {
    const reader = new FileReader();
    reader.readAsDataURL(blob);
    reader.onloadend = function () {
      resolve(reader.result);
    };
  });
};

(async () => {
  const b64 = await blobToBase64(blob);
  const jsonString = JSON.stringify({blob: b64});
  console.log(jsonString);
})();
Posted by: Guest on November-08-2020
0

javascript stringify blob

const parsed = JSON.parse(jsonString);
const blob = await fetch(parsed.blob).then(res => res.blob());
console.log(blob);
Posted by: Guest on November-08-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language