mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
* 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
20 lines
612 B
TypeScript
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)
|
|
}
|