I wrote some code to create a REST api to handle customer's infomation and a file from them,I want to save the file they upload to my local disk on server.My code is as below
@RequestMapping(value = "/alg", method = RequestMethod.POST)
public String postUsersNewAlg(@RequestParam(value = "file", required = true) CommonsMultipartFile jarfile,
@RequestParam(value = "username", required = true) String userName,
@RequestParam(value = "output", required = true) String output) {
//other code handles string infos etc.
try {
//get directory path that to save file
String filePath = PathUtil.getOffAlgJarFilePathRoot();
//get file path
String filePathWhole = null;
if (!filePath.endsWith(SeparatorUtils.getFileSeparator())) {
filePathWhole = filePath + SeparatorUtils.getFileSeparator() + algImpl.getOriginalFilename();
}
else {
filePathWhole = filePath + algImpl.getOriginalFilename();
}
FileUtil.copyFile(jarfile, filePath,filePathWhole);
}
catch(Exception e){
e.printStackTrace();
return e.getMessage();
}
}
Problem is a java.lang.NoClassDefFoundError:org/apache/commons/fileupload/FileUploadException] with root cause.So how can I do this?Thanks in advance.