diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-01-09 14:10:23 +0100 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2020-01-09 14:11:39 +0100 |
commit | 205ed5b7dcc4ac8b1bc9a02ff2201261c5075633 (patch) | |
tree | bbdc4cda7cf2814c59999153eefc87700a8b47ae /server/middlewares/validators/videos/video-captions.ts | |
parent | f44a284a3e863cac144d1675208a38422ac0fc8c (diff) | |
download | PeerTube-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/validators/videos/video-captions.ts')
-rw-r--r-- | server/middlewares/validators/videos/video-captions.ts | 8 |
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' | |||
2 | import { areValidationErrors } from '../utils' | 2 | import { areValidationErrors } from '../utils' |
3 | import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' | 3 | import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' |
4 | import { body, param } from 'express-validator' | 4 | import { body, param } from 'express-validator' |
5 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' | 5 | import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants' |
6 | import { UserRight } from '../../../../shared' | 6 | import { UserRight } from '../../../../shared' |
7 | import { logger } from '../../../helpers/logger' | 7 | import { logger } from '../../../helpers/logger' |
8 | import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions' | 8 | import { 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) => { |