diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-07 10:36:13 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-04-08 10:07:53 +0200 |
commit | 213e30ef90806369529684ac9c247d73b8dc7928 (patch) | |
tree | 7f834f2485a074b1d3052745fa5236d34c0f26db /server/helpers/custom-validators/actor-images.ts | |
parent | 2cb03dc1f4e01ba491c36caff30c33fe9c5bad89 (diff) | |
download | PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.gz PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.zst PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.zip |
Add banner tests
Diffstat (limited to 'server/helpers/custom-validators/actor-images.ts')
-rw-r--r-- | server/helpers/custom-validators/actor-images.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/actor-images.ts b/server/helpers/custom-validators/actor-images.ts new file mode 100644 index 000000000..4fb0b7c70 --- /dev/null +++ b/server/helpers/custom-validators/actor-images.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | |||
2 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | ||
3 | import { isFileValid } from './misc' | ||
4 | |||
5 | const imageMimeTypes = CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME | ||
6 | .map(v => v.replace('.', '')) | ||
7 | .join('|') | ||
8 | const imageMimeTypesRegex = `image/(${imageMimeTypes})` | ||
9 | function isActorImageFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], fieldname: string) { | ||
10 | return isFileValid(files, imageMimeTypesRegex, fieldname, CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max) | ||
11 | } | ||
12 | |||
13 | // --------------------------------------------------------------------------- | ||
14 | |||
15 | export { | ||
16 | isActorImageFile | ||
17 | } | ||