// add arquivo @RequestMapping(method = RequestMethod.POST) public @ResponseBody Long handleFileUpload(@RequestParam("file") MultipartFile file) { log.debug("Documento - POST"); if (!file.isEmpty()) { try { if (file.getBytes() != null && file.getBytes().length != 0) { Documento documento = new Documento(); documento.setArquivo(file.getBytes()); documento.setNome(file.getOriginalFilename()); documento.setNomeOriginal(file.getOriginalFilename()); documento.setTipo(file.getContentType()); serviceDocumento.save(documento); // retornar o ID do documento return documento.getId(); } } catch (IOException ioe) { return (long) -1; } } return (long) -1; }