@RequestMapping(value = "hunter/addressbooks/upload", method = RequestMethod.POST) public Object upload( @RequestParam Long id, @RequestParam String companyName, @RequestParam(required = false) MultipartFile file) { Addressbook book = new Addressbook(); book.setId(id); String fileName = file.getOriginalFilename(); book.setAttachmentName(fileName); String pathname = path + companyName + "/"; book.setAttachmentPath(pathname); try { File directory = new File(pathname + fileName); if (!directory.exists()) { directory.mkdirs(); } file.transferTo(directory); } catch (Exception e) { throw new RuntimeException(e); } addressbookService.update(book); return true; }
@RequestMapping(value = "hunter/addressbooks/{id}", method = RequestMethod.PUT) public Object update(@PathVariable Long id, @RequestBody Addressbook book) { book.setId(id); addressbookService.update(book); return true; }