2021-04-07 03:36:13 -05:00
|
|
|
|
2022-02-11 03:51:33 -06:00
|
|
|
import { UploadFilesForCheck } from 'express'
|
2021-04-07 03:36:13 -05:00
|
|
|
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})`
|
2022-02-11 03:51:33 -06:00
|
|
|
|
|
|
|
function isActorImageFile (files: UploadFilesForCheck, fieldname: string) {
|
|
|
|
return isFileValid({
|
|
|
|
files,
|
|
|
|
mimeTypeRegex: imageMimeTypesRegex,
|
|
|
|
field: fieldname,
|
|
|
|
maxSize: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
|
|
|
|
})
|
2021-04-07 03:36:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
isActorImageFile
|
|
|
|
}
|