From 7f58cf51c0feb67d4b8398b84c24f85d0a38dba3 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 31 Oct 2023 21:29:43 -0700 Subject: [PATCH] image: refactor params Signed-off-by: Varun Patil --- lib/Controller/ImageController.php | 10 ++-------- src/components/frame/XImgWorker.ts | 6 ++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/Controller/ImageController.php b/lib/Controller/ImageController.php index dae6f8d3..77a28d73 100644 --- a/lib/Controller/ImageController.php +++ b/lib/Controller/ImageController.php @@ -76,15 +76,9 @@ class ImageController extends GenericApiController * * Get preview of many images */ - public function multipreview(): Http\Response + public function multipreview(array $files): Http\Response { - return Util::guardExDirect(function (Http\IOutput $out) { - // read body to array - $body = file_get_contents('php://input'); - - /** @var array */ - $files = json_decode($body, true); - + return Util::guardExDirect(function (Http\IOutput $out) use ($files) { // Filter files with valid parameters $files = array_filter($files, static function (array $file) { return isset($file['reqid'], $file['fileid'], $file['x'], $file['y'], $file['a']) diff --git a/src/components/frame/XImgWorker.ts b/src/components/frame/XImgWorker.ts index b6bef576..9373a018 100644 --- a/src/components/frame/XImgWorker.ts +++ b/src/components/frame/XImgWorker.ts @@ -303,10 +303,8 @@ async function fetchOneImage(url: string) { async function fetchMultipreview(files: any[]) { return await fetch(config.multiUrl, { method: 'POST', - body: JSON.stringify(files), - headers: { - 'Content-Type': 'application/json', - }, + body: JSON.stringify({ files }), + headers: { 'Content-Type': 'application/json' }, }); }