25 lines
No EOL
490 B
Markdown
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' });
|
|
``` |