Files
lens/src/renderer/utils/downloadFile.ts
T
2020-11-19 16:35:04 +02:00

12 lines
409 B
TypeScript

export function downloadFile(filename: string, contents: any, type: string) {
const data = new Blob([contents], { type: type });
const url = URL.createObjectURL(data);
const link = document.createElement("a");
link.href = url;
link.download = filename;
link.style.display = "none";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}