-function areErrorsInVideoImageFiles (req: express.Request, res: express.Response) {
- // Files are optional
- if (!req.files) return false
-
- for (const imageField of [ 'thumbnail', 'preview' ]) {
- if (!req.files[ imageField ]) continue
-
- const imageFile = req.files[ imageField ][ 0 ] as Express.Multer.File
- if (imageFile.size > CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max) {
- res.status(400)
- .json({ error: `The size of the ${imageField} is too big (>${CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max}).` })
- .end()
- return true
- }
- }
-
- return false
-}
-