}
videos.videosAdd = function (req, res, next) {
- req.checkFiles('input_video.originalname', 'Should have an input video').notEmpty()
- req.checkFiles('input_video.mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i)
+ req.checkFiles('input_video[0].originalname', 'Should have an input video').notEmpty()
+ req.checkFiles('input_video[0].mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i)
req.checkBody('name', 'Should have a name').isLength(1, 50)
req.checkBody('description', 'Should have a description').isLength(1, 250)
"grunt": "^0.4.5",
"grunt-browserify": "^4.0.1",
"grunt-concurrent": "^2.1.0",
- "grunt-contrib-clean": "^0.6.0",
- "grunt-contrib-copy": "0.8.0",
+ "grunt-contrib-clean": "^0.7.0",
+ "grunt-contrib-copy": "0.8.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-express-server": "^0.5.1",
"grunt-newer": "^1.1.1",
"mkdirp": "^0.5.1",
"mongoose": "^4.0.5",
"morgan": "^1.5.3",
- "multer": "^0.1.8",
- "node-ipc": "^3.0.0",
+ "multer": "^1.1.0",
+ "node-ipc": "^4.1.0",
"openssl-wrapper": "https://github.com/Chocobozzz/node-openssl-wrapper",
"request": "^2.57.0",
"request-replay": "^0.3.0",
- "segfault-handler": "^0.2.4",
+ "segfault-handler": "^1.0.0",
"time-grunt": "^1.2.1",
"ursa": "^0.9.1",
"validator": "^4.3.0",
- "webtorrent": "*",
- "winston": "^1.0.1",
+ "webtorrent": "^0.63.2",
+ "winston": "^2.1.1",
"ws": "^0.8.0"
},
"devDependencies": {
'use strict'
var express = require('express')
+ var config = require('config')
+ var multer = require('multer')
var router = express.Router()
+
var middleware = require('../../../middlewares')
var miscMiddleware = middleware.misc
var reqValidator = middleware.reqValidators.videos
var videos = require('../../../src/videos')
+ var uploads = config.get('storage.uploads')
+
function listVideos (req, res, next) {
videos.list(function (err, videos_list) {
if (err) return next(err)
}
function addVideos (req, res, next) {
- videos.add({ video: req.files.input_video, data: req.body }, function (err) {
+ videos.add({ video: req.files.input_video[0], data: req.body }, function (err) {
if (err) return next(err)
// TODO : include Location of the new video
})
}
+ var reqFiles = multer({ dest: uploads }).fields([{ name: 'input_video', maxCount: 1 }])
+
router.get('/', miscMiddleware.cache(false), listVideos)
- router.post('/', reqValidator.videosAdd, miscMiddleware.cache(false), addVideos)
+ router.post('/', reqFiles, reqValidator.videosAdd, miscMiddleware.cache(false), addVideos)
router.get('/search/:name', reqValidator.videosSearch, miscMiddleware.cache(false), searchVideos)
router.get('/:id', reqValidator.videosGet, miscMiddleware.cache(false), getVideos)
router.delete('/:id', reqValidator.videosRemove, miscMiddleware.cache(false), removeVideo)
var expressValidator = require('express-validator')
var http = require('http')
var morgan = require('morgan')
- var multer = require('multer')
var path = require('path')
var TrackerServer = require('bittorrent-tracker').Server
var WebSocketServer = require('ws').Server
// Get configurations
var port = config.get('listen.port')
- var uploads = config.get('storage.uploads')
// ----------- Command line -----------
app.use(morgan('combined', { stream: logger.stream }))
// For body requests
app.use(bodyParser.json())
- // For POST file requests
- app.use(multer({ dest: uploads }))
app.use(bodyParser.urlencoded({ extended: false }))
// Validate some params for the API
app.use(expressValidator({
var params = {
name: video_data.name,
- namePath: video_file.name,
+ namePath: video_file.filename,
description: video_data.description,
magnetUri: torrent.magnetURI,
podUrl: http + '://' + host + ':' + port