2021-04-07 04:36:13 -04:00
|
|
|
|
2022-02-11 04:51:33 -05:00
|
|
|
import { UploadFilesForCheck } from 'express'
|
2021-04-07 04:36:13 -04: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 04:51:33 -05: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 04:36:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
isActorImageFile
|
|
|
|
}
|