diff options
Diffstat (limited to 'server/helpers/custom-validators/video-imports.ts')
-rw-r--r-- | server/helpers/custom-validators/video-imports.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/video-imports.ts b/server/helpers/custom-validators/video-imports.ts index dbf6a3504..af93aea56 100644 --- a/server/helpers/custom-validators/video-imports.ts +++ b/server/helpers/custom-validators/video-imports.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import { UploadFilesForCheck } from 'express' | ||
2 | import validator from 'validator' | 3 | import validator from 'validator' |
3 | import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants' | 4 | import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants' |
4 | import { exists, isFileValid } from './misc' | 5 | import { exists, isFileValid } from './misc' |
@@ -25,8 +26,14 @@ const videoTorrentImportRegex = Object.keys(MIMETYPES.TORRENT.MIMETYPE_EXT) | |||
25 | .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream | 26 | .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream |
26 | .map(m => `(${m})`) | 27 | .map(m => `(${m})`) |
27 | .join('|') | 28 | .join('|') |
28 | function isVideoImportTorrentFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) { | 29 | function isVideoImportTorrentFile (files: UploadFilesForCheck) { |
29 | return isFileValid(files, videoTorrentImportRegex, 'torrentfile', CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, true) | 30 | return isFileValid({ |
31 | files, | ||
32 | mimeTypeRegex: videoTorrentImportRegex, | ||
33 | field: 'torrentfile', | ||
34 | maxSize: CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, | ||
35 | optional: true | ||
36 | }) | ||
30 | } | 37 | } |
31 | 38 | ||
32 | // --------------------------------------------------------------------------- | 39 | // --------------------------------------------------------------------------- |