How to set max image size in Joi/Hapi

Viewed 5507

I am using nodejs+mongodb. In the front-end while uploading the image it doesn't allow if the size is more than 50kb. I want to set it upto 5MB so that I can upload the image if the size is 1MB or 2MB. I have tried many way I have googled it but still I dint get proper solution. I checked in this link [Joi/hapi][1]

[1]: https://github.com/hapijs/joi/blob/v9.0.1/API.md but still did not work. Can anybody please help me

Here is my schema

const nameofSchema = Joi.object().keys({
description: Joi.string(), // .required(),
image: Joi.string().max(500000),

category: Joi.string(),
namesasd: Joi.string().regex(/^[a-z][a-z0-9-]*$/),
title: Joi.string(), // .required(),
price: Joi.number().integer(),
tag: Joi.object().keys({
    tag_name: Joi.string()
})
});

In this for image I want to set max limit size 5mb.(to upload upto 5mb size image)

Below is route

create: {
    description: '',
    path: '/',
    verb: 'post'
},
1 Answers
Related