MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / downloadFileFromText

Function downloadFileFromText

frontend/packages/common/src/utils/download.ts:65–78  ·  view source on GitHub ↗
(fileName: string, text: string)

Source from the content-addressed store, hash-verified

63}
64
65export const downloadFileFromText = (fileName: string, text: string) => {
66 const file = new Blob([text], { type: 'data:text/plain;charset=utf-8' })
67
68 const element = document.createElement('a')
69 const url = URL.createObjectURL(file)
70 element.href = url
71 element.download = fileName
72 document.body.appendChild(element)
73 element.click()
74 Promise.resolve().then(() => {
75 document.body.removeChild(element)
76 window.URL.revokeObjectURL(url)
77 })
78}

Callers

nothing calls this directly

Calls 1

createElementMethod · 0.45

Tested by

no test coverage detected