From 63a30ed0831655b34ba329a731183d7192d7aa19 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 19 Mar 2024 12:15:39 +0200 Subject: [PATCH] maximumFileSize fix --- app/controllers/api/storage.php | 4 +++- app/init.php | 3 +++ composer.lock | 17 +++++++++-------- docker-compose.yml | 1 + 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 26ae0adacf..4ee330c320 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -2,9 +2,11 @@ use Appwrite\Auth\Auth; use Appwrite\Auth\Hash\Sha; +use Appwrite\Auth\Validator\PasswordDictionary; use Appwrite\ClamAV\Network; use Appwrite\Event\Delete; use Appwrite\Event\Event; +use Appwrite\Hooks\Hooks; use Appwrite\Utopia\Database\Validator\CustomId; use Appwrite\OpenSSL\OpenSSL; use Appwrite\Utopia\Response; @@ -65,7 +67,7 @@ App::post('/v1/storage/buckets') ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('fileSecurity', false, new Boolean(true), 'Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true) - ->param('maximumFileSize', (int) App::getEnv('_APP_STORAGE_LIMIT', 0), new Range(1, (int) App::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true) + ->param('maximumFileSize', fn (array $plan) => empty($plan['fileSize']) ? (int) App::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1024 * 1024, fn (array $plan) => new Range(1, empty($plan['fileSize']) ? (int) App::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1024 * 1024), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true, ['plan']) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) diff --git a/app/init.php b/app/init.php index cd97fba276..ec7fa7163b 100644 --- a/app/init.php +++ b/app/init.php @@ -1494,3 +1494,6 @@ App::setResource('requestTimestamp', function ($request) { } return $requestTimestamp; }, ['request']); +App::setResource('plan', function (array $plan = []) { + return []; +}); diff --git a/composer.lock b/composer.lock index 606338c675..0d7d13460a 100644 --- a/composer.lock +++ b/composer.lock @@ -1393,16 +1393,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.3", + "version": "0.33.4", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "893d602cd96676810c25fc9b9a2e9360eebb898f" + "reference": "6ee2e93a4a529bce5eecf4ac892890d4b0c84861" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/893d602cd96676810c25fc9b9a2e9360eebb898f", - "reference": "893d602cd96676810c25fc9b9a2e9360eebb898f", + "url": "https://api.github.com/repos/utopia-php/http/zipball/6ee2e93a4a529bce5eecf4ac892890d4b0c84861", + "reference": "6ee2e93a4a529bce5eecf4ac892890d4b0c84861", "shasum": "" }, "require": { @@ -1417,7 +1417,8 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\": "src/" + "Utopia\\": "src/", + "Tests\\E2E\\": "tests/e2e" } }, "notification-url": "https://packagist.org/downloads/", @@ -1432,9 +1433,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.3" + "source": "https://github.com/utopia-php/http/tree/0.33.4" }, - "time": "2024-03-11T13:43:23+00:00" + "time": "2024-03-19T08:04:59+00:00" }, { "name": "utopia-php/image", @@ -5169,5 +5170,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } diff --git a/docker-compose.yml b/docker-compose.yml index 26c5301526..da60452513 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -84,6 +84,7 @@ services: - ./public:/usr/src/code/public - ./src:/usr/src/code/src - ./dev:/usr/src/code/dev + - ./vendor/utopia-php/framework:/usr/src/code/vendor/utopia-php/framework depends_on: - mariadb - redis