aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/actor-images.ts
blob: 89f5a226212d5d7f87f6efc5e487aa7d54a1deca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { UploadFilesForCheck } from 'express'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { isFileValid } from './misc'

const imageMimeTypes = CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
  .map(v => v.replace('.', ''))
  .join('|')
const imageMimeTypesRegex = `image/(${imageMimeTypes})`

function isActorImageFile (files: UploadFilesForCheck, fieldname: string) {
  return isFileValid({
    files,
    mimeTypeRegex: imageMimeTypesRegex,
    field: fieldname,
    maxSize: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
  })
}

// ---------------------------------------------------------------------------

export {
  isActorImageFile
}