aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-01-09 14:10:23 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-01-09 14:11:39 +0100
commit205ed5b7dcc4ac8b1bc9a02ff2201261c5075633 (patch)
treebbdc4cda7cf2814c59999153eefc87700a8b47ae /server/middlewares
parentf44a284a3e863cac144d1675208a38422ac0fc8c (diff)
downloadPeerTube-205ed5b7dcc4ac8b1bc9a02ff2201261c5075633.tar.gz
PeerTube-205ed5b7dcc4ac8b1bc9a02ff2201261c5075633.tar.zst
PeerTube-205ed5b7dcc4ac8b1bc9a02ff2201261c5075633.zip
Add video caption upload documentation and improve error message
fixes #2038
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/videos/video-captions.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.ts
index 2fb1da5ce..7b0cd6f66 100644
--- a/server/middlewares/validators/videos/video-captions.ts
+++ b/server/middlewares/validators/videos/video-captions.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { areValidationErrors } from '../utils' 2import { areValidationErrors } from '../utils'
3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
4import { body, param } from 'express-validator' 4import { body, param } from 'express-validator'
5import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' 5import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants'
6import { UserRight } from '../../../../shared' 6import { UserRight } from '../../../../shared'
7import { logger } from '../../../helpers/logger' 7import { logger } from '../../../helpers/logger'
8import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions' 8import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
@@ -13,9 +13,9 @@ const addVideoCaptionValidator = [
13 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), 13 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'),
14 param('captionLanguage').custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'), 14 param('captionLanguage').custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'),
15 body('captionfile') 15 body('captionfile')
16 .custom((value, { req }) => isVideoCaptionFile(req.files, 'captionfile')).withMessage( 16 .custom((_, { req }) => isVideoCaptionFile(req.files, 'captionfile')).withMessage(
17 'This caption file is not supported or too large. Please, make sure it is of the following type : ' 17 `This caption file is not supported or too large. Please, make sure it is under ${CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE} and one of the following mimetypes: `
18 + CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME.join(', ') 18 + Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT).map(key => `${key} (${MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT[key]})`).join(', ')
19 ), 19 ),
20 20
21 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 21 async (req: express.Request, res: express.Response, next: express.NextFunction) => {