connectiopn fix round 2 3

This commit is contained in:
2026-08-21 16:02:23 +02:00
parent 8c9af78672
commit 763be3e7bf
12 changed files with 708 additions and 11 deletions

View File

@ -206,8 +206,16 @@
`/ssh/${hostId}/files/upload?remote_path=${encodeURIComponent(remotePath)}`,
{ method: "POST", credentials: "same-origin", body: formData }
);
const data = await res.json();
if (!res.ok) throw new Error(data.detail || "Upload fehlgeschlagen");
// Robust gegen Nicht-JSON-Antworten (z.B. ein unbehandelter serverseitiger
// Fehler, den Starlette als Klartext "Internal Server Error" statt JSON
// ausliefert) -- sonst crasht hier res.json() mit einer verwirrenden
// "Unexpected token 'I' ..."-Meldung statt der eigentlichen Fehlerursache
// (siehe GET .../files/download, das dasselbe Muster schon nutzt).
let data = null;
try {
data = await res.json();
} catch (_) { /* Antwort war kein JSON */ }
if (!res.ok) throw new Error((data && data.detail) || `Upload fehlgeschlagen (HTTP ${res.status})`);
ftStatus.textContent = `Upload abgeschlossen (AV: ${data.av_scan_result})`;
recordTransfer("upload", file.name, data.size, true, "");
uploadFileInput.value = "";