I'm using Joi to validate requests. I'm wondering how should I validate uploaded file size with Joi.
I'm sending many files as a stream.
To limits the size of incoming payloads to the specified byte count you can use as follow:
route.options.payload.maxBytes
for example:
payload: {
maxBytes: 20715200,
output: 'stream',
parse: true,
allow: 'multipart/form-data'
},
validate: {
payload: {
bannerImage: Joi.any()
.meta({swaggerType: 'file'})
.optional()
.allow('')
.description('image file'),
},
failAction: UniversalFunctions.failActionFunction
},