Good day,
I write server code (java, spring) that serves GET request. The response should be in multipart-form format and should include 2 parts: string (json object) and file data.
The code is:
FileSystemResource resource = new FileSystemResource(targetFile);
String info = getInfo(targetFile);
MultiValueMap<String, Object> form = new LinkedMultiValueMap<String, Object>();
form.add("info", info);
form.add("file", resource);
MediaType multiPart =
MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE);
ResponseEntity <MultiValueMap<String, Object>> responseEntity =
ResponseEntity.ok().contentType(multiPart).body(form);
return responseEntity;
The code works OK, but I didn't find a way to define content type of parts. For first part it should be application/json, and for second part it depends on file type.
How to define this?