Rest API request size

I am using Jmix rest to expose the API for a front-end to invoke.

We have a feature to allow user to upload profile photo. The profile photo is sent to the API using base64 encode.

My question is: as I don’t want user to upload a very big profile photo, in Jmix, how can I limit the size of http request?

I am not using the Files API to upload the file, the base64 encoded profile photo is sent to the server in one request together with other user info like username, display name etc.

I would recommend creating a custom controller endpoint and accept the file in a separate MultipartFile parameter. Then perhaps the spring.servlet.multipart.max-file-size property will apply to it.

Thanks for the suggestion. I will have a try.

@krivopustov I tried the way you suggested, it works. It can limit the upload size as expected.

I met another issue - I need only logged in user to invoke the API. In rest api, those APIs were protected. Not sure how I can do it in controller.


I know how to do it now.

I added the URLs to the application.properties file’s jmix.rest.authenticated-url-patterns properties, such as:


jmix.rest.authenticated-url-patterns = \
  /user/*

1 Like