diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/video-captions.ts | 6 | ||||
-rw-r--r-- | server/helpers/express-utils.ts | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts index 6a9c6d75c..177e9e86e 100644 --- a/server/helpers/custom-validators/video-captions.ts +++ b/server/helpers/custom-validators/video-captions.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { CONSTRAINTS_FIELDS, VIDEO_CAPTIONS_MIMETYPE_EXT, VIDEO_LANGUAGES, VIDEO_MIMETYPE_EXT } from '../../initializers' | 1 | import { CONSTRAINTS_FIELDS, VIDEO_CAPTIONS_MIMETYPE_EXT, VIDEO_LANGUAGES } from '../../initializers' |
2 | import { exists, isFileValid } from './misc' | 2 | import { exists, isFileValid } from './misc' |
3 | import { Response } from 'express' | 3 | import { Response } from 'express' |
4 | import { VideoModel } from '../../models/video/video' | 4 | import { VideoModel } from '../../models/video/video' |
@@ -8,7 +8,9 @@ function isVideoCaptionLanguageValid (value: any) { | |||
8 | return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined | 8 | return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined |
9 | } | 9 | } |
10 | 10 | ||
11 | const videoCaptionTypes = Object.keys(VIDEO_CAPTIONS_MIMETYPE_EXT).map(m => `(${m})`) | 11 | const videoCaptionTypes = Object.keys(VIDEO_CAPTIONS_MIMETYPE_EXT) |
12 | .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream >< | ||
13 | .map(m => `(${m})`) | ||
12 | const videoCaptionTypesRegex = videoCaptionTypes.join('|') | 14 | const videoCaptionTypesRegex = videoCaptionTypes.join('|') |
13 | function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], field: string) { | 15 | function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], field: string) { |
14 | return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) | 16 | return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) |
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index f136a4329..b3cc40848 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts | |||
@@ -4,6 +4,7 @@ import { CONFIG, REMOTE_SCHEME } from '../initializers' | |||
4 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | import { User } from '../../shared/models/users' | 5 | import { User } from '../../shared/models/users' |
6 | import { generateRandomString } from './utils' | 6 | import { generateRandomString } from './utils' |
7 | import { extname } from 'path' | ||
7 | 8 | ||
8 | function buildNSFWFilter (res: express.Response, paramNSFW?: string) { | 9 | function buildNSFWFilter (res: express.Response, paramNSFW?: string) { |
9 | if (paramNSFW === 'true') return true | 10 | if (paramNSFW === 'true') return true |
@@ -50,7 +51,7 @@ function createReqFiles ( | |||
50 | }, | 51 | }, |
51 | 52 | ||
52 | filename: async (req, file, cb) => { | 53 | filename: async (req, file, cb) => { |
53 | const extension = mimeTypes[ file.mimetype ] | 54 | const extension = mimeTypes[ file.mimetype ] || extname(file.originalname) |
54 | let randomString = '' | 55 | let randomString = '' |
55 | 56 | ||
56 | try { | 57 | try { |