Spaces:
deepak191z
/
Runtime error

RAI / src /utils /download.ts
deepak191z's picture
Upload 84 files
229b3b8 verified
raw
history blame contribute delete
578 Bytes
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));
};