aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/reqValidators/videos.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/server/middlewares/reqValidators/videos.js b/server/middlewares/reqValidators/videos.js
index c20660452..6e6e75fb3 100644
--- a/server/middlewares/reqValidators/videos.js
+++ b/server/middlewares/reqValidators/videos.js
@@ -1,6 +1,7 @@
1'use strict' 1'use strict'
2 2
3const checkErrors = require('./utils').checkErrors 3const checkErrors = require('./utils').checkErrors
4const constants = require('../../initializers/constants')
4const logger = require('../../helpers/logger') 5const logger = require('../../helpers/logger')
5const videos = require('../../lib/videos') 6const videos = require('../../lib/videos')
6const Videos = require('../../models/videos') 7const Videos = require('../../models/videos')
@@ -20,7 +21,22 @@ function videosAdd (req, res, next) {
20 21
21 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) 22 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })
22 23
23 checkErrors(req, res, next) 24 checkErrors(req, res, function () {
25 const videoFile = req.files.videofile[0]
26
27 videos.getVideoDuration(videoFile.path, function (err, duration) {
28 if (err) {
29 return res.status(400).send('Cannot retrieve metadata of the file.')
30 }
31
32 if (duration > constants.MAXIMUM_VIDEO_DURATION) {
33 return res.status(400).send('Duration of the video file is too big.')
34 }
35
36 videoFile.duration = duration
37 next()
38 })
39 })
24} 40}
25 41
26function videosGet (req, res, next) { 42function videosGet (req, res, next) {