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:
parent
c4082b8b4e
commit
0c237b19fd
9 changed files with 59 additions and 39 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue