文件下载
public ResponseEntity<byte[]> downloadArchiveFile(String name,String filepath) throws IOException {}
/**
* @Description: 文件下载
* @Param: [file, fileName]
* @return: org.springframework.http.ResponseEntity<byte[]>
* @about=>yangjianzhi-version1.0-2019/4/15
*/
public static ResponseEntity<byte[]> getFileResponse(File file, String fileName) throws IOException {
HttpHeaders headers = new HttpHeaders();
String filename = new String(fileName.getBytes("utf-8"), "iso-8859-1");
headers.setContentDispositionFormData("attachment", filename);
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers, HttpStatus.CREATED);
}