MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / downloadFile

Function downloadFile

console/src/utils/downloadFile.ts:22–37  ·  view source on GitHub ↗
(
  fileName: string,
  contents: string,
  options: DownloadFileOptions = { mimeType: "text/plain" },
)

Source from the content-addressed store, hash-verified

20 * @param options (optional) additional properties for the file
21 */
22export function downloadFile(
23 fileName: string,
24 contents: string,
25 options: DownloadFileOptions = { mimeType: "text/plain" },
26) {
27 const file = new Blob([contents], { type: options.mimeType });
28 const url = URL.createObjectURL(file);
29 const element = document.createElement("a");
30 element.href = url;
31 element.download = fileName;
32 document.body.appendChild(element);
33 element.click();
34 // Cleanup
35 element.remove();
36 URL.revokeObjectURL(url);
37}

Callers 2

downloadCsvFunction · 0.90

Calls 1

removeMethod · 0.45

Tested by

no test coverage detected