+ checkErrors(req, res, function () {
+ const videoFile = req.files.videofile[0]
+
+ videos.getVideoDuration(videoFile.path, function (err, duration) {
+ if (err) {
+ return res.status(400).send('Cannot retrieve metadata of the file.')
+ }
+
+ if (duration > constants.MAXIMUM_VIDEO_DURATION) {
+ return res.status(400).send('Duration of the video file is too big (' + constants.MAXIMUM_VIDEO_DURATION + ').')
+ }
+
+ videoFile.duration = duration
+ next()
+ })
+ })