I am using the mentioned fileuplaod middleware. I want to setup a middleware that warns on file size limit exceed but don't want to truncate the file.
app.use(fileUpload({
limits: { fileSize: 1 * 1024 * 1024 },
createParentPath: true,
safeFileNames: true,
preserveExtension: 5,
limitHandler: function (req, res, next) {
Logger.warn("File size limit has been exceeded");
},
abortOnLimit: false,
useTempFiles: true,
tempFileDir: './temp/apiuploads'
}));
The files are getting truncated. Hence the files that are uploaded cant be opened. I want to log the message when file size limit exceed but don't want to truncate the file. Please help me with a solution.