Spaces:
Runtime error
Runtime error
export const download = (url: string, filename: string) => { | |
fetch(url) | |
.then((response) => response.blob()) | |
.then((blob) => { | |
const url = window.URL.createObjectURL(blob); | |
const link = document.createElement('a'); | |
link.href = url; | |
link.setAttribute('download', `${filename}.mp4`); // Specify the filename for the downloaded video | |
document.body.appendChild(link); | |
link.click(); | |
link.parentNode.removeChild(link); | |
window.URL.revokeObjectURL(url); | |
}) | |
.catch((error) => console.error('Download error:', error)); | |
}; | |