Use raw file uploads

This commit is contained in:
Mikei386
2026-06-23 21:45:51 +02:00
parent 9d5903dcf6
commit 1d8149606a
6 changed files with 60 additions and 22 deletions
+14 -6
View File
@@ -904,13 +904,21 @@ async function uploadFileList(win, files, targetPath) {
const uploadItems = normalizeUploadItems(files);
for (const [index, item] of uploadItems.entries()) {
recordDebug('upload.file.request', { path: item.path, size: item.file.size, index: index + 1, total: uploadItems.length });
const form = new FormData();
form.append('files', item.file, item.file.name);
form.append('relativePath', item.path);
appendCsrf(form);
await fetchChecked(apiUrl(`upload.php?path=${encodeURIComponent(targetPath)}`), {
const params = new URLSearchParams({
path: targetPath,
relativePath: item.path
});
const token = getCsrfToken();
if (token) {
params.set('csrf_token', token);
recordDebug('csrf.attached', { length: token.length });
} else {
recordDebug('csrf.missing', {});
}
await fetchChecked(apiUrl(`upload.php?${params.toString()}`), {
method: 'POST',
body: form
headers: { 'Content-Type': 'application/octet-stream' },
body: item.file
});
recordDebug('upload.file.done', { path: item.path, index: index + 1, total: uploadItems.length });
}