UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

20 lines (18 loc) 540 B
export const downloadFile = async (url: string, fileName: string) => { try { const res = await fetch(url); const blob = await res.blob(); const blobUrl = window.URL.createObjectURL(blob); const link = document.createElement('a'); link.href = blobUrl; link.download = fileName; link.style.display = 'none'; document.body.append(link); link.click(); link.remove(); window.URL.revokeObjectURL(blobUrl); } catch (error) { console.log('Download failed:', error); window.open(url); } };