I have a spring boot service which need to validate multipart max file size in different rest routes for example all v1 routes for 5MB and v2 for 10MB
e.g: api/v1/route1 -> max file upload size is 5MB
api/v2/route2 -> max file upload size is 10MB
api/v2/route3 -> max file upload size is 2MB
Already below is set but then all request would be validate against it include v1 route
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
I was thinking what is the best way to implement it.
Is it keep the max 10MB limit as general value as above in application level and in each route do the validations using MultipartFile getSize() method
Any other better way to do it in a interceptor or something by checking request path?