Use raw file uploads
This commit is contained in:
+14
-6
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user