mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
07c479fdab
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
16 lines
485 B
TypeScript
16 lines
485 B
TypeScript
/**
|
|
* Save a Blob as a file using the browser download path (no pop-up).
|
|
* Works after async fetch when the response is same-origin (e.g. /api/workspace/download?stream).
|
|
*/
|
|
export function triggerBlobDownload(blob: Blob, filename: string): void {
|
|
const url = URL.createObjectURL(blob);
|
|
const a = document.createElement("a");
|
|
a.href = url;
|
|
a.download = filename;
|
|
a.rel = "noopener";
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
a.remove();
|
|
URL.revokeObjectURL(url);
|
|
}
|