diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 05fd3c2aa1..3b5dda6250 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -991,7 +991,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') // Check bucket-level image transformations flag $allowImageTransformations = $bucket->getAttribute('imageTransformations', true); - if (!$allowImageTransformations && !$isToken) { + if (!$allowImageTransformations && !$isToken && !$isPrivilegedUser) { // Image transformations are disabled for this bucket throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED); } diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 2e250b6cc4..14663a2816 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -589,8 +589,8 @@ App::init() $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getSequence(); // Only proceed for preview when not disabled; other routes unaffected - // Skip the block for privileged console users and resource tokens. - if ($isImageTransformation && $isImageTransformationsBlocked && !$isPrivilegedUser && !$isToken) { + // Skip the block only when transformations remain enabled. + if ($isImageTransformation && $isImageTransformationsBlocked) { throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED); } @@ -636,7 +636,9 @@ App::init() ->addHeader('Cache-Control', sprintf('private, max-age=%d', $timestamp)) ->addHeader('X-Appwrite-Cache', 'hit') ->setContentType($cacheLog->getAttribute('mimeType')); - if (!$isImageTransformation || !$isImageTransformationsBlocked) { + // Determine if user can bypass transformation blocks + $canBypassBlock = ($type === 'bucket') && ($isPrivilegedUser || $isToken); + if (!$isImageTransformation || !$isImageTransformationsBlocked || $canBypassBlock) { $response->send($data); } } else {