Specify expected file size in the manifest

As of the last Sitevision release (Cloud and On-prem), zero is accepted as valid value for the maxUploadSizeInMB in the manifest. From now on we recommend to always specify maxUploadSizeInMB.

The manifest has support for the maxUploadSizeInMB property that specifies the max accepted file size the app expects to receive and process. The last released Cloud (2023.11.1.2) and On-prem (2023.10.1.4) versions of Sitevision now supports zero as a valid value, so now there are really no excuses to not always specify maxUploadSizeInMB.

The reason to always specify the maxUploadSizeInMB property is twofold:

  1. Documentation. The manifest explicitly states whether or not the app expects any request file data.
  2. Validation and control. A non-zero value bounds the size of expected request file data, i.e. blocks unreasonably large files to be handled by the app.

Apps with non-payload routes (GET, DELETE)

WebApps and RESTApps that only use non-payload routes should always specify maxUploadSizeInMB as zero. It will clearly state that "this app does not expect file data in any request".

// manifest.json
{
   ...
   "maxUploadSizeInMB": 0  // This app does not handle any file data
}	

Apps with potential payload routes (POST, PUT, PATCH)

WebApps and RESTApps that use payload routes should specify the maxUploadSizeInMB value according to the implemented behaviour of the app.

The app should specify zero as value if no route expects any file data in the request.

// manifest.json
{
   ...
   "maxUploadSizeInMB": 0  // This app does not handle any file data
}	

The app should specify a reasonable value if any route expects file data in the request.

// manifest.json
{
   ...
   "maxUploadSizeInMB": 6  // This app handles file data (max 6 MB file data expected)
}	
// index.js
import router from "@sitevision/api/common/router";
...

router.get("/", (req, res) => {
   ...
});

router.post("/upload", (req, res) => {
   const file = req.file('file'); // This route handles file data...
   ...
});

Do you want to subscribe to News from Sitevision Developer team? Subscribe here!