]>
Commit | Line | Data |
---|---|---|
74dc3bca | 1 | import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' |
40e87e9e | 2 | import { exists, isFileValid } from './misc' |
40e87e9e C |
3 | |
4 | function isVideoCaptionLanguageValid (value: any) { | |
a1587156 | 5 | return exists(value) && VIDEO_LANGUAGES[value] !== undefined |
40e87e9e C |
6 | } |
7 | ||
edaf5b86 C |
8 | const videoCaptionTypesRegex = Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT) |
9 | .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream | |
2769e297 | 10 | .map(m => `(${m})`) |
edaf5b86 | 11 | .join('|') |
40e87e9e | 12 | function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], field: string) { |
f4001cf4 | 13 | return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) |
40e87e9e C |
14 | } |
15 | ||
40e87e9e C |
16 | // --------------------------------------------------------------------------- |
17 | ||
18 | export { | |
19 | isVideoCaptionFile, | |
3e753302 | 20 | isVideoCaptionLanguageValid |
40e87e9e | 21 | } |