Files
html/api/blade-upload.php
OpusWIRE 06938edbbf
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
V9.36 multiagent dispatch + Blade threshold 1800s + WTP entrypoint + autonomy full
2026-04-20 16:59:51 +02:00

32 lines
1014 B
PHP

<?php
// Blade upload endpoint - accepts base64 files from Blade Agent
header("Content-Type: application/json");
$key = "BLADE2026";
$data = json_decode(file_get_contents("php://input"), true);
if (!$data || ($data["k"] ?? "") !== $key) {
http_response_code(403);
die(json_encode(["error" => "auth"]));
}
$name = preg_replace('/[^a-zA-Z0-9._-]/', '_', $data["name"] ?? "file.bin");
$b64 = $data["b64"] ?? "";
if (strlen($b64) < 10 || strlen($b64) > 20_000_000) {
http_response_code(400);
die(json_encode(["error" => "invalid b64 length"]));
}
$bytes = base64_decode($b64, true);
if ($bytes === false) {
http_response_code(400);
die(json_encode(["error" => "invalid base64"]));
}
$dir = "/var/www/html/api/blade-tasks/uploads";
if (!is_dir($dir)) mkdir($dir, 0755, true);
$path = $dir . "/" . date("Ymd_His_") . $name;
file_put_contents($path, $bytes);
chmod($path, 0644);
echo json_encode([
"ok" => true,
"saved_to" => $path,
"size" => strlen($bytes),
"ts" => date("c")
]);