+ checkErrors(req, res, function () {
+ const videoFile = req.files.videofile[0]
+
+ Video.getDurationFromFile(videoFile.path, function (err, duration) {
+ if (err) {
+ return res.status(400).send('Cannot retrieve metadata of the file.')
+ }
+
+ if (!customValidators.isVideoDurationValid(duration)) {
+ return res.status(400).send('Duration of the video file is too big (max: ' + constants.VIDEOS_CONSTRAINTS_FIELDS.DURATION.max + 's).')
+ }
+
+ videoFile.duration = duration
+ next()
+ })
+ })