aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/reqValidators/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-16 19:49:10 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-16 19:49:10 +0200
commit67100f1f971dd10a466a321899b56c0813e08d31 (patch)
tree3253db23a9dca2273fd2c9702fb3b6f1801c0f1c /server/middlewares/reqValidators/videos.js
parentdcc7b3fe470fe5f1546c0f3e7c28c07fc54633c5 (diff)
downloadPeerTube-67100f1f971dd10a466a321899b56c0813e08d31.tar.gz
PeerTube-67100f1f971dd10a466a321899b56c0813e08d31.tar.zst
PeerTube-67100f1f971dd10a466a321899b56c0813e08d31.zip
Add a check for the duration of videos
Diffstat (limited to 'server/middlewares/reqValidators/videos.js')
-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) {