My webapp is using Spring MVC. Endpoint below allows user to download a file. When the user saves the file (Chrome, MSIE) in the browser it is broken. It size is 28792 bytes instead of 24567 and content seems to have different encoding. I spent a day trying to fix that but no success. Source file works fine. Please advise. Thanks a lot!
@RequestMapping(method = POST, consumes = MULTIPART_FORM_DATA_VALUE)
public void processFile(MultipartFile file, HttpServletResponse response) {
try {
response.setHeader("Content-Encoding","UTF-8");
Files.copy(Paths.get("c:\\files", "worksheet.xls"), response.getOutputStream());
response.getOutputStream().flush();
} catch (Exception ignore) {
}
}