From e8ff828039bd2e60c003d9a828b6ea5196a76052 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 28 Dec 2023 01:31:25 +0000 Subject: [PATCH] fix for file extension not supported - the error occured with jfif extension, which is essentially a jpeg file --- app/controllers/api/storage.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 1fae48dae0..8600752734 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -915,6 +915,12 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') } if (empty($output)) { + // when file extension is provided but it's not one of our + // supported outputs we fallback to `jpg` + if(!empty($type) && !array_key_exists($type, $outputs)) { + $type = 'jpg'; + } + // when file extension is not provided and the mime type is not one of our supported outputs // we fallback to `jpg` output format $output = empty($type) ? (array_search($mime, $outputs) ?? 'jpg') : $type;