aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/misc.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-22 15:42:55 +0200
committerChocobozzz <me@florianbigard.com>2018-06-22 15:42:55 +0200
commit0c237b19fdf9c614293c1442f0ab95a81ce05735 (patch)
tree81f7ae4262630da5e8041bd70e2cb856e48253a3 /server/helpers/custom-validators/misc.ts
parentc4082b8b4e3684baae0172e97297c936d7419f2c (diff)
downloadPeerTube-0c237b19fdf9c614293c1442f0ab95a81ce05735.tar.gz
PeerTube-0c237b19fdf9c614293c1442f0ab95a81ce05735.tar.zst
PeerTube-0c237b19fdf9c614293c1442f0ab95a81ce05735.zip
Fix images size limit
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r--server/helpers/custom-validators/misc.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 254b4db6c..455aae367 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -45,6 +45,7 @@ function isFileValid (
45 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], 45 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
46 mimeTypeRegex: string, 46 mimeTypeRegex: string,
47 field: string, 47 field: string,
48 maxSize: number,
48 optional = false 49 optional = false
49) { 50) {
50 // Should have files 51 // Should have files
@@ -61,6 +62,9 @@ function isFileValid (
61 const file = fileArray[ 0 ] 62 const file = fileArray[ 0 ]
62 if (!file || !file.originalname) return false 63 if (!file || !file.originalname) return false
63 64
65 // Check size
66 if (maxSize && file.size > maxSize) return false
67
64 return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype) 68 return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype)
65} 69}
66 70