PeerTube/server/helpers/custom-validators/actor-images.ts

25 lines
665 B
TypeScript
Raw Normal View History

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