Come sto provando con spring boot e webservices con i componenti aggiuntivi di chrome postman.La richiesta è stata rifiutata perché non è stato trovato alcun limite multipart in springboot
Nel postino content-type="multipart/form-data"
e ricevo l'eccezione seguente.
HTTP Status 500 - Request processing failed;
nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request;
nested exception is java.io.IOException:
org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
controller ho specificato il codice qui sotto
@ResponseBody
@RequestMapping(value = "/file", headers = "Content-Type= multipart/form-data", method = RequestMethod.POST)
public String upload(@RequestParam("name") String name,
@RequestParam(value = "file", required = true) MultipartFile file)
//@RequestParam()CommonsMultipartFile[] fileUpload
{
// @RequestMapping(value="/newDocument", , method = RequestMethod.POST)
if (!file.isEmpty()) {
try {
byte[] fileContent = file.getBytes();
fileSystemHandler.create(123, fileContent, name);
return "You successfully uploaded " + name + "!";
} catch (Exception e) {
return "You failed to upload " + name + " => " + e.getMessage();
}
} else {
return "You failed to upload " + name + " because the file was empty.";
}
}
Qui ho specificare il codice del gestore di file
public String create(int jonId, byte[] fileContent, String name) {
String status = "Created file...";
try {
String path = env.getProperty("file.uploadPath") + name;
File newFile = new File(path);
newFile.createNewFile();
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(newFile));
stream.write(fileContent);
stream.close();
} catch (IOException ex) {
status = "Failed to create file...";
Logger.getLogger(FileSystemHandler.class.getName()).log(Level.SEVERE, null, ex);
}
return status;
}
anche io di fronte allo stesso problema, e il suo unico lavoro in postino non funziona w con altri strumenti come "Advance rest client". posso sapere perché? – Narendhran