Files
overleaf-cep/services/web/frontend/js/utils/download-file.ts
T
Domagoj Kriskovic a301363ece Move Library BibTeX export to a server-side endpoint (#36604)
* Move bulk bibtex download to a server-side streaming endpoint

* Wrap download fetch errors in FetchError and parse the error body

* Refactor library references download to use GET request and stream response

* Remove MAX_DOWNLOAD_IDS limit from downloadIdsSchema and related test

* fix merge conflict

GitOrigin-RevId: dee2bae8bfb982cd1b79bbd21c9f1b90e8cff1a4
2026-09-17 12:01:40 +00:00

20 lines
612 B
TypeScript

export function downloadFileContent(content: string, filename: string) {
const blob = new Blob([content], { type: 'application/octet-stream' })
const url = URL.createObjectURL(blob)
clickDownloadLink(url, filename)
setTimeout(() => URL.revokeObjectURL(url), 0)
}
export function downloadFileFromUrl(url: string, filename: string) {
clickDownloadLink(url, filename)
}
function clickDownloadLink(url: string, filename: string) {
const link = document.createElement('a')
link.href = url
link.download = filename
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}