Spring endpoint accepting multipart JSON + Uploaded file
To accept a multipart composed by a file and also JSON content, you can define the endpoint with two @RequestPart with the name name of the part (“json”, and “file” for the actual uploaded file). Keep those two names in mind as they’ll be needed later.
The json part is your POJO (MyJsonContentRequest) with the request data.
The uploaded file is the Spring MultipartFile class that has method to get the original file name, MIME and of…