how to convert string into blob in javascript
const str2blob = txt => new Blob([txt]);
how to convert string into blob in javascript
const str2blob = txt => new Blob([txt]);
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);
})();
javascript stringify blob
const parsed = JSON.parse(jsonString);
const blob = await fetch(parsed.blob).then(res => res.blob());
console.log(blob);
js string to blob
In order to extract data from a Blob, you need a FileReader.
var reader = new FileReader();
reader.onload = function() {
alert(reader.result);
}
reader.readAsText(blob);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us