I try to upload an image to a server using the postman. I am using spring to make the rest api as the followings:
@RequestMapping(value = "/uploadPrescription", method =RequestMethod.POST)
public ResponseEntity<ResponseSuccessData> uploadPatientPrescription(
@RequestBody @RequestParam("image") MultipartFile image)
throws IOException {
But it throws an error:
org.springframework.web.bind.MissingServletRequestParameterException:
Required MultipartFile parameter 'image' is not present
As you can see in the postman that key name is 'image' and in rest api is also @RequestParam("image").
Setting value in content type - Content-type = multipart/form-data,boundaries='--abc'
This is my spring config for multipart -
@Bean
public CommonsMultipartResolver multipartResolver() {
CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
//commonsMultipartResolver.setMaxUploadSize(-1);
return commonsMultipartResolver;
}
What could be the problem?