How to set the import limit of records with NodeJS?

Viewed 25

i have created a middleware that can handle the upload file but right now i have a problem that i do not know how to set the limit that you can only import in one time. For example: you import a .xlsx file but you want that can only 2000 records. So, now i have a question that how to set the limit records and maybe infinite limit of records. Thanks for your help

const storage = multer.diskStorage({
    destination: function(req, file, cb) {
        cb(null, 'uploads/');
    },

    // By default, multer removes file extensions so let's add them back
    filename: function(req, file, cb) {
        cb(null, file.fieldname + '-' + Date.now() + path.extname(file.originalname));
    }
});

If you have any ideas or find something wrong, please tell me and we can talk together

0 Answers
Related