joplin-notes/joplin notion extension/Web Development/Javascript/blob file download.md
2026-11-04 00:33:23 +05:30

490 B

blob file download

const download=()=>{
    fetch(`${HOST}`,{

    })
    .then(res=>res.blob())
    .then(blob=>{
        const url = URL.createObjectURL(blob);
      const link = document.createElement("a");
      link.download = "extraordinary12.mp3";
      link.href = url;
      link.click();
    })
    .catch(console.log)
}

creating a text blob

const textData = "Hello, this is my text content!";
const textBlob = new Blob([textData], { type: 'text/plain' });