MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / downloadFile

Function downloadFile

devtools/modules/utils.js:132–148  ·  view source on GitHub ↗
(content, filename, mimeType)

Source from the content-addressed store, hash-verified

130}
131
132export function downloadFile(content, filename, mimeType) {
133 const bom = mimeType === 'text/csv' ? '\uFEFF' : '';
134 const blob = new Blob([bom + content], { type: mimeType + ';charset=utf-8' });
135 const url = URL.createObjectURL(blob);
136
137 const a = document.createElement('a');
138 a.href = url;
139 a.download = filename;
140 a.style.display = 'none';
141 document.body.appendChild(a);
142 a.click();
143
144 setTimeout(() => {
145 document.body.removeChild(a);
146 URL.revokeObjectURL(url);
147 }, 100);
148}

Callers 3

exportToJSONFunction · 0.90
exportCurrentToCSVFunction · 0.90
exportAllToCSVFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected