diff --git a/CHANGES.md b/CHANGES.md index d8e177b25..51239015f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,8 @@ * Upgraded SMTP image to version 1.0.1 * File upload route (POST /v1/storage/files) now accept a single file per request * Added ENV vars to change system email sender name and address +* Usage for requests made by project admin in the console are not counted as API usage +* Added ENV var to change default file upload size limit. New default value is 100MB ## Bug Fixes diff --git a/Dockerfile b/Dockerfile index d7be8224a..47b8bad8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,7 @@ ENV TZ=Asia/Tel_Aviv \ _APP_EDITION=community \ _APP_OPTIONS_ABUSE=enabled \ _APP_OPENSSL_KEY_V1=your-secret-key \ + _APP_STORAGE_LIMIT=104857600 \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ @@ -95,8 +96,9 @@ RUN \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Set Upload Limit -RUN echo "upload_max_filesize = 4M" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini +# Set Upload Limit (default to 100MB) +RUN echo "upload_max_filesize = ${_APP_STORAGE_LIMIT}" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini +RUN echo "post_max_size = ${_APP_STORAGE_LIMIT}" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini # Nginx Configuration (with self-signed ssl certificates) COPY ./docker/nginx.conf /etc/nginx/nginx.conf diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 04cf1dba7..ad1beef9a 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -172,9 +172,9 @@ $utopia->get('/v1/health/stats') 'version' => shell_exec('nginx -v 2>&1'), ], 'storage' => [ - 'used' => $device->human($device->getDirectorySize($device->getRoot().'/')), - 'partitionTotal' => $device->human($device->getPartitionTotalSpace()), - 'partitionFree' => $device->human($device->getPartitionFreeSpace()), + 'used' => Storage::human($device->getDirectorySize($device->getRoot().'/')), + 'partitionTotal' => Storage::human($device->getPartitionTotalSpace()), + 'partitionFree' => Storage::human($device->getPartitionFreeSpace()), ], 'cache' => [ 'uptime' => (isset($cacheStats['uptime_in_seconds'])) ? $cacheStats['uptime_in_seconds'] : 0, diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 58e949d0f..a166a9076 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -139,7 +139,7 @@ $utopia->post('/v1/storage/files') * Validators */ //$fileType = new FileType(array(FileType::FILE_TYPE_PNG, FileType::FILE_TYPE_GIF, FileType::FILE_TYPE_JPEG)); - $fileSize = new FileSize(2097152 * 2); // 4MB + $fileSize = new FileSize($request->getServer('_APP_STORAGE_LIMIT', 0)); $upload = new Upload(); if (empty($file)) { diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index a91cff909..dae9737e4 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -7,6 +7,7 @@ global $utopia, $response, $request, $layout, $version, $providers, $projectDB; use Utopia\View; use Database\Database; use Database\Validator\UID; +use Storage\Storage; $utopia->init(function () use ($layout, $utopia) { $layout @@ -203,9 +204,11 @@ $utopia->get('/console/storage') ->label('scope', 'console') ->action(function () use ($request, $layout) { $page = new View(__DIR__.'/../../views/console/storage/index.phtml'); - + $page - ->setParam('home', $request->getServer('_APP_HOME', '')) + ->setParam('home', $request->getServer('_APP_HOME', 0)) + ->setParam('fileLimit', $request->getServer('_APP_STORAGE_LIMIT', 0)) + ->setParam('fileLimitHuman', Storage::human($request->getServer('_APP_STORAGE_LIMIT', 0))) ; $layout diff --git a/app/views/console/storage/index.phtml b/app/views/console/storage/index.phtml index 420bd76f5..776950e9d 100644 --- a/app/views/console/storage/index.phtml +++ b/app/views/console/storage/index.phtml @@ -1,5 +1,7 @@ getParam('home', ''); +$fileLimit = $this->getParam('fileLimit', 0); +$fileLimitHuman = $this->getParam('fileLimitHuman', 0); ?>