I want to pass a file path as a String to DAO Class through service Class to store in the mySQL database using REST Controller. I tried with some approach but it's not working. Any idea on this?
@RequestMapping(value="/upload", method=RequestMethod.POST, headers=("content-type=multipart/*"))
public @ResponseBody void handleFileUpload(@RequestParam("file") MultipartFile file) {
String itr = file.getOriginalFilename();
fileMeta = new Document();
try {
fileMeta.setBytes(file.getBytes());
FileCopyUtils.copy(file.getBytes(), new FileOutputStream("D:/temp/files/"+file.getOriginalFilename()));
} catch (IOException e) {
e.printStackTrace();
}
}