Rename a file with multer is not working

I'm trying to rename a file using multer. I want to rename the file uploaded to a .jpg Instead of the tutorial about multer, i'm calling the method rename in my route file. The file is well uploaded but I don't get why the function rename is not working. By the way, the word 'ici' doesn't appear into my console

router.post('/edit/saveEdit',multer({
rename : function(fieldname, filename, req, res) {
    console.log('ici');
    return req.body.infoUser.id
}}),
function(req,res){

// console.log(req.body);
// console.log(JSON.stringify(req.files));

var conf = JSON.parse(fs.readFileSync(file_user));
var user = req.body.infoUser;


//changement de nom de fichier
// console.log(req.files.uploadAvatar);

Thanks for answers/help Thibault

res.end('good');

try using multer first for performing the desired operation on file and then serving the request. example :

router.use(multer({ 
  dest: './path/to/folder',
    rename : function (fieldname, filename, req, res) {
       console.log('ici');
       return req.body.infoUser.id
    }
  }
)));

router.post('/edit/saveEdit', function(req, res){
    // Operations saveEdit is hit
});