Confirm raw upload responses

This commit is contained in:
Mikei386
2026-06-23 21:50:34 +02:00
parent 1d8149606a
commit c661cbaf46
6 changed files with 28 additions and 18 deletions
+21 -1
View File
@@ -915,11 +915,31 @@ async function uploadFileList(win, files, targetPath) {
} else {
recordDebug('csrf.missing', {});
}
await fetchChecked(apiUrl(`upload.php?${params.toString()}`), {
const response = await fetch(apiUrl(`upload.php?${params.toString()}`), {
method: 'POST',
headers: { 'Content-Type': 'application/octet-stream' },
body: item.file
});
const text = await response.text();
recordDebug('upload.file.response', {
path: item.path,
status: response.status,
ok: response.ok,
contentType: response.headers.get('content-type'),
body: text.slice(0, 1000)
});
if (!response.ok) {
throw new Error(text || `${response.status} ${response.statusText}`);
}
let payload;
try {
payload = JSON.parse(text);
} catch (error) {
throw new Error(`Upload lieferte keine JSON-Antwort: ${text.slice(0, 200) || response.headers.get('content-type') || 'leer'}`);
}
if (!payload.uploaded?.length) {
throw new Error('Upload wurde vom Server nicht bestätigt.');
}
recordDebug('upload.file.done', { path: item.path, index: index + 1, total: uploadItems.length });
}
await loadExplorer(win, targetPath);