MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / downloadText

Function downloadText

frontend/src/utils/exportUtils.ts:146–165  ·  view source on GitHub ↗
(
  content: string, 
  filename: string = 'DataKit_Export',
  extension: string = 'txt'
)

Source from the content-addressed store, hash-verified

144 * Download text content as a file
145 */
146export const downloadText = (
147 content: string,
148 filename: string = 'DataKit_Export',
149 extension: string = 'txt'
150): void => {
151 try {
152 const blob = new Blob([content], { type: 'text/plain' });
153 const url = URL.createObjectURL(blob);
154 const a = document.createElement('a');
155 a.href = url;
156 a.download = `${filename}.${extension}`;
157 document.body.appendChild(a);
158 a.click();
159 document.body.removeChild(a);
160 URL.revokeObjectURL(url);
161 } catch (error) {
162 console.error('Failed to download text:', error);
163 throw new Error('Text download failed. Please try again.');
164 }
165};
166
167/**
168 * Create styled HTML content for PDF export

Callers 2

exportQueryAsCSVFunction · 0.90
exportQueryAsSQLFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected