1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Fix images size limit

This commit is contained in:
Chocobozzz 2018-06-22 15:42:55 +02:00
parent c4082b8b4e
commit 0c237b19fd
No known key found for this signature in database
GPG key ID: 583A612D890159BE
9 changed files with 59 additions and 39 deletions

View file

@ -45,6 +45,7 @@ function isFileValid (
files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
mimeTypeRegex: string,
field: string,
maxSize: number,
optional = false
) {
// Should have files
@ -61,6 +62,9 @@ function isFileValid (
const file = fileArray[ 0 ]
if (!file || !file.originalname) return false
// Check size
if (maxSize && file.size > maxSize) return false
return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype)
}