I am able to upload file Using Form data as given below
but when i am trying to upload file by selecting binary as input getting error as given below;
{"timestamp":1490680735011,"status":500,"error":"Internal Server Error","exception":"org.springframework.web.multipart.MultipartException","message":"Current request is not a multipart request","path":"/uploadBinary"}
for that i am writing code as
@RequestMapping(value = "/uploadBinary", method = RequestMethod.POST)
public ResponseEntity<Object> uploadBinary(
@RequestParam("file") MultipartFile[] multipartFiles) {
try {
System.out.println("starting....");
fileService.upload(multipartFiles);
System.out.println("uploaded successfully ");
} catch (Exception ex) {
System.out.println(ex.getMessage());
return new ResponseEntity<Object>(new String(
"Something Went wrong while uploading data to server"),
HttpStatus.OK);
}
return new ResponseEntity<Object>(new String("uploaded successfully "),
HttpStatus.OK);
}
this works fine for uploading form data, but for binary selection its not working. how we resolve this issues??
Check whether you have added CommonsMultipartResolver in your spring configuration file
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>