diff --git a/app/config/errors.php b/app/config/errors.php index 8365e8c705..5b21f1099a 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -497,6 +497,11 @@ return [ 'description' => 'The requested file is not publicly readable.', 'code' => 403, ], + Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED => [ + 'name' => Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED, + 'description' => 'Image transformations are disabled for this storage bucket.', + 'code' => 401, + ], /** Tokens */ Exception::TOKEN_NOT_FOUND => [ diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index c547679c35..05fd3c2aa1 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -993,7 +993,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $allowImageTransformations = $bucket->getAttribute('imageTransformations', true); if (!$allowImageTransformations && !$isToken) { // Image transformations are disabled for this bucket - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED); } if ($fileSecurity && !$valid && !$isToken) { diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index f1c974923a..2e250b6cc4 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -591,7 +591,7 @@ App::init() // 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) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::STORAGE_IMAGE_TRANSFORMATIONS_DISABLED); } if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAppUser && !$isPrivilegedUser)) { diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 3af6d9962c..0173631d27 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -148,6 +148,7 @@ class Exception extends \Exception public const STORAGE_INVALID_RANGE = 'storage_invalid_range'; public const STORAGE_INVALID_APPWRITE_ID = 'storage_invalid_appwrite_id'; public const STORAGE_FILE_NOT_PUBLIC = 'storage_file_not_public'; + public const STORAGE_IMAGE_TRANSFORMATIONS_DISABLED = 'storage_image_transformations_disabled'; /** VCS */ public const INSTALLATION_NOT_FOUND = 'installation_not_found';