Basic and very raw implementation of the Reply To feature.

This commit is contained in:
aforge
2021-08-14 16:30:18 +03:00
parent 47e7632399
commit b482f6649d
9 changed files with 457 additions and 15 deletions
+24
View File
@@ -244,3 +244,27 @@ export function base64ReEncode(str) {
}
return str;
}
// Convert a base64 encoded string with the provided mime type into a Blob.
export function base64ToBlob(str, mime) {
if (!str) {
return null;
}
try {
// Make blob.
const bin = atob(str);
const length = bin.length;
const buf = new ArrayBuffer(length);
const arr = new Uint8Array(buf);
for (let i = 0; i < length; i++) {
arr[i] = bin.charCodeAt(i);
}
return new Blob([buf], { type: mime });
} catch(err) {
console.log("Failed to convert base64 to blob: ", err);
}
return null;
}