Commit 0e2ed4efa1b6d59a0fd73be2a94493d887deb06a

Authored by 谭苏航
1 parent ceabb0f6

feat: use authenticated user phone for upload path

Showing 1 changed file with 10 additions and 2 deletions
@@ -492,7 +492,11 @@ $http_worker->onMessage = function ($connection, $request) use ($config, $authSe @@ -492,7 +492,11 @@ $http_worker->onMessage = function ($connection, $request) use ($config, $authSe
492 492
493 // Generate Key 493 // Generate Key
494 $uuid = bin2hex(random_bytes(8)); 494 $uuid = bin2hex(random_bytes(8));
495 - $userPhone = $config['upload']['default_user']; 495 +
  496 + // Determine User Phone (Auth > Config)
  497 + $user = $getUser();
  498 + $userPhone = $user ? $user['phone'] : $config['upload']['default_user'];
  499 +
496 $objectKey = "clawdbot/{$userPhone}/{$uuid}.{$ext}"; 500 $objectKey = "clawdbot/{$userPhone}/{$uuid}.{$ext}";
497 $bucket = $tos_config['bucket']; 501 $bucket = $tos_config['bucket'];
498 502
@@ -548,7 +552,11 @@ $http_worker->onMessage = function ($connection, $request) use ($config, $authSe @@ -548,7 +552,11 @@ $http_worker->onMessage = function ($connection, $request) use ($config, $authSe
548 ]); 552 ]);
549 553
550 $uuid = bin2hex(random_bytes(8)); 554 $uuid = bin2hex(random_bytes(8));
551 - $userPhone = $config['upload']['default_user']; 555 +
  556 + // Determine User Phone (Auth > Config)
  557 + $user = $getUser();
  558 + $userPhone = $user ? $user['phone'] : $config['upload']['default_user'];
  559 +
552 // Ensure filename is safe 560 // Ensure filename is safe
553 $safeName = preg_replace('/[^a-zA-Z0-9._-]/', '', $filename); 561 $safeName = preg_replace('/[^a-zA-Z0-9._-]/', '', $filename);
554 if (!$safeName) 562 if (!$safeName)
Please register or login to post a comment