Confirm raw upload responses
This commit is contained in:
+21
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user