public StreamingResponseBody downloadTemplate(HttpServletResponse response) throws IOException {
response.setContentType(“application/octet-stream”);
response.setHeader(“Content-Disposition”, “attachment; filename=” + templateFile.getFilename());
ServletOutputStream outputStream = response.getOutputStream();
return stream -> {
int bytesRead;
byte[] buffer = new byte[1024];
InputStream inputStream = templateFile.getInputStream();
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
};
}
@Value(“classpath:template/bcid_template.xlsx”)
private org.springframework.core.io.Resource templateFile;