I have a save image function that looks like this:
async saveImage(image: Blob, key: string) {
// using: https://developer.mozilla.org/en-US/docs/Web/API/Blob/text
const content = await image.text();
window.localStorage.setItem(key, content);
}
Now I like to create a load Image function looking like this:
async loadImage(key: string) : Blob {
const item = window.localStorage.getItem(key);
const imageBlob = ???
return imageBlob;
}
How can I convert the USVString that was generated by Blob.text()
back to a new Blob()
?