Skip to content

Commit

Permalink
Create DataBlobUrls.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jobisoft committed Dec 6, 2023
1 parent b3dff71 commit 8ca89ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions includes/DataBlobUrls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const image = await fetch("https://raw.githubusercontent.com/thunderbird/sample-extensions/master/hello-world/images/internet.png")
const imageBlob = await image.blob();

// Retrieve a data: url.
const dataUrl = await new Promise(resolve => {
var reader = new FileReader();
reader.onload = (e) => resolve(e.target.result);
reader.readAsDataURL(imageBlob);
})

// Retrieve a blob: url.
const blobUrl = URL.createObjectURL(imageBlob);

0 comments on commit 8ca89ff

Please sign in to comment.