forked from MarceloClaro/AUXJURIS_V2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
15 lines (14 loc) · 638 Bytes
/
utils.ts
File metadata and controls
15 lines (14 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Utility function to trigger file download in the browser
export const downloadFile = (content: string, filename: string, mimeType: string): void => {
const blob = new Blob([content], { type: mimeType });
const link = document.createElement("a");
const dataUrl = URL.createObjectURL(blob);
link.setAttribute("href", dataUrl);
link.setAttribute("download", filename);
document.body.appendChild(link); // Required for Firefox
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(dataUrl); // Clean up the object URL
console.log(`Downloaded ${filename}`);
};
// Other utility functions can be added here.