Spaces:
Sleeping
Sleeping
Download src/lib/triggerDownload.ts from ChrisJohnson111/test100: direct link, hf CLI and curl.
- Browser
- Download file 383 Bytes
-
https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/triggerDownload.ts
- Command line
-
hf download hf://spaces/ChrisJohnson111/test100/src/lib/triggerDownload.ts
-
curl -L -o triggerDownload.ts https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/triggerDownload.ts
383 Bytes
| export function triggerDownload(filename: string, text: string) { | |
| var element = document.createElement('a'); | |
| element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
| element.setAttribute('download', filename); | |
| element.style.display = 'none'; | |
| document.body.appendChild(element); | |
| element.click(); | |
| document.body.removeChild(element); | |
| } |