I using springboot 1.5.4.RELEASE with java 1.8 and I create a controller that allow download a file from a restController this is my code:
@RequestMapping(value = "/validar/{hash}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody byte[] getArquivoFromHash(@PathVariable String hash) throws IOException {
return IOUtils.toByteArray(protocoloService.recuperarArquivoCertidaoAssinado(hash));
}
and my recuperarArquivoCertidaoAssinado returns a FileInputStream from a File
so when I try to download a large file (something like 50MB) I got the heapspace
java.lang.OutOfMemoryError: Java heap space