I'm developing a simple app that will allow users to upload their content. I want to limit the file size which Express will accept. I know I can use
app.use(express.limit('2mb'));
but I want to change the limit dynamically. Certain users will have higher limits.
The best solution would be to FIRST check the content-length header and THEN start to parse the upload if file size is below the limit but Express automatically saves file uploads to disk (/tmp directory). So if someone sends 1GB file, this file will be parsed and saved to disk even when I don't want to allow that.
Thanks in advance!