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

25 lines
No EOL
490 B
Markdown

blob file download
```jsx
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
```js
const textData = "Hello, this is my text content!";
const textBlob = new Blob([textData], { type: 'text/plain' });
```