/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/utils/downloadFile.ts
22 строки
734 B
Krasnov Dmitry
fix: preserve raw bytes when downloading topic messages (#4130)
23 июл 2026, 15:24
Не верифицирован
23 июл 2026, 15:24
3ad3ce9
Код
Авторство
О чём код?
export function downloadFile(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); } export const createAndDownloadFile = (data: BlobPart, fileName: string, type?: string) => { const blob = new Blob([data], { type, }); const url = URL.createObjectURL(blob); downloadFile(url, fileName); URL.revokeObjectURL(url); }; export const createAndDownloadJsonFile = (data: unknown, fileName: string) => { const preparedData = JSON.stringify(data, null, 2); createAndDownloadFile(preparedData, `${fileName}.json`, 'application/json'); };