Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/ui/api/ssh-file-operations-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ function buildFileManagerUrl(path: string): string {
return `${baseURL.replace(/\/$/, "")}${path}`;
}

function triggerBlobDownload(blob: Blob, fileName: string): void {
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = fileName;
link.style.display = "none";

document.body.appendChild(link);
link.click();

window.setTimeout(() => {
link.remove();
URL.revokeObjectURL(url);
}, 1000);
}

async function uploadSSHFileInChunks(
sessionId: string,
path: string,
Expand Down Expand Up @@ -492,12 +508,7 @@ export async function downloadSSHFileStream(
);
const blob = response.data as Blob;
const fileName = filePath.split("/").pop() || "download";
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
a.click();
URL.revokeObjectURL(url);
triggerBlobDownload(blob, fileName);
}

export async function createSSHFile(
Expand Down
Loading