Confirm raw upload responses
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
PLUGIN="u-navigator"
|
PLUGIN="u-navigator"
|
||||||
VERSION="2026.06.23.r046"
|
VERSION="2026.06.23.r047"
|
||||||
PKG_DIR="packages"
|
PKG_DIR="packages"
|
||||||
WORK_DIR=".plugin-build"
|
WORK_DIR=".plugin-build"
|
||||||
PKG_NAME="${PLUGIN}-${VERSION}.tgz"
|
PKG_NAME="${PLUGIN}-${VERSION}.tgz"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -10,24 +10,14 @@ if (!is_dir($target['path'])) {
|
|||||||
if (isset($_GET['relativePath']) || isset($_SERVER['HTTP_X_UNAV_RELATIVE_PATH'])) {
|
if (isset($_GET['relativePath']) || isset($_SERVER['HTTP_X_UNAV_RELATIVE_PATH'])) {
|
||||||
$relativeName = (string)($_GET['relativePath'] ?? $_SERVER['HTTP_X_UNAV_RELATIVE_PATH']);
|
$relativeName = (string)($_GET['relativePath'] ?? $_SERVER['HTTP_X_UNAV_RELATIVE_PATH']);
|
||||||
$destination = unav_prepare_upload_destination($target['path'], $relativeName);
|
$destination = unav_prepare_upload_destination($target['path'], $relativeName);
|
||||||
$input = fopen('php://input', 'rb');
|
$bytes = file_put_contents($destination['path'], file_get_contents('php://input'), LOCK_EX);
|
||||||
$output = fopen($destination['path'], 'xb');
|
if ($bytes === false) {
|
||||||
if (!$input || !$output) {
|
unav_error(500, 'Could not store uploaded file');
|
||||||
if ($input) {
|
|
||||||
fclose($input);
|
|
||||||
}
|
|
||||||
if ($output) {
|
|
||||||
fclose($output);
|
|
||||||
}
|
|
||||||
unav_error(500, 'Could not open upload stream');
|
|
||||||
}
|
}
|
||||||
stream_copy_to_stream($input, $output);
|
|
||||||
fclose($input);
|
|
||||||
fclose($output);
|
|
||||||
unav_json([
|
unav_json([
|
||||||
'uploaded' => [[
|
'uploaded' => [[
|
||||||
'name' => $destination['relative'],
|
'name' => $destination['relative'],
|
||||||
'size' => filesize($destination['path']) ?: 0,
|
'size' => $bytes,
|
||||||
]],
|
]],
|
||||||
], 201);
|
], 201);
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -915,11 +915,31 @@ async function uploadFileList(win, files, targetPath) {
|
|||||||
} else {
|
} else {
|
||||||
recordDebug('csrf.missing', {});
|
recordDebug('csrf.missing', {});
|
||||||
}
|
}
|
||||||
await fetchChecked(apiUrl(`upload.php?${params.toString()}`), {
|
const response = await fetch(apiUrl(`upload.php?${params.toString()}`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
headers: { 'Content-Type': 'application/octet-stream' },
|
||||||
body: item.file
|
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 });
|
recordDebug('upload.file.done', { path: item.path, index: index + 1, total: uploadItems.length });
|
||||||
}
|
}
|
||||||
await loadExplorer(win, targetPath);
|
await loadExplorer(win, targetPath);
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE PLUGIN [
|
<!DOCTYPE PLUGIN [
|
||||||
<!ENTITY name "u-navigator">
|
<!ENTITY name "u-navigator">
|
||||||
<!ENTITY author "Michael Roll">
|
<!ENTITY author "Michael Roll">
|
||||||
<!ENTITY version "2026.06.23.r046">
|
<!ENTITY version "2026.06.23.r047">
|
||||||
<!ENTITY package "&name;-&version;.tgz">
|
<!ENTITY package "&name;-&version;.tgz">
|
||||||
<!ENTITY pluginURL "https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
<!ENTITY pluginURL "https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
||||||
<!ENTITY support "https://git.casaderoll.de/michael/Unraid-Navigator">
|
<!ENTITY support "https://git.casaderoll.de/michael/Unraid-Navigator">
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<FILE Name="/boot/config/plugins/&name;/&package;">
|
<FILE Name="/boot/config/plugins/&name;/&package;">
|
||||||
<URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL>
|
<URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL>
|
||||||
<MD5>acb81bdc26294c48b2115013cac89015</MD5>
|
<MD5>3c9e5a641720371ec7cee8bd70a32d8e</MD5>
|
||||||
</FILE>
|
</FILE>
|
||||||
|
|
||||||
<FILE Run="/bin/bash">
|
<FILE Run="/bin/bash">
|
||||||
|
|||||||
Reference in New Issue
Block a user