UNPKG

vamtec-react

Version:

Vamtec is a file generation (PDF, Excel, CSV), image uploads handling and automation library

12 lines (10 loc) 361 B
const DownloadFile = (baseFilename, fileExtension, data) => { const filename = `${baseFilename}.${fileExtension}`; const link = document.createElement('a'); link.href = window.URL.createObjectURL(new Blob([data])); link.setAttribute('download', filename); document.body.appendChild(link); link.click(); link.remove(); }; export { DownloadFile };