-
Notifications
You must be signed in to change notification settings - Fork 145
Description
When I use url from my controller. The reader can't run anyway.
Anyone can help?
controller:
When I use url from my controller. The reader can't run anyway.
Anyone can help?
controller:
@GetMapping("/epub/ebook/{id}")
public ResponseEntity<byte[]> getEPUB(@PathVariable Integer id) throws IOException{
String filePath = "C:\epub\1010490076.epub";
File file = new File(filePath);
if (file.exists()) {
}
FileInputStream fileInputStream = new FileInputStream(file);
byte[] fileByte = fileInputStream.readAllBytes();
fileInputStream.close();
HttpHeaders header = new HttpHeaders();
header.add(HttpHeaders.CONTENT_TYPE, "application/epub+zip");
header.setContentDisposition(ContentDisposition.attachment().filename("xxxx.epub", StandardCharsets.UTF_8).build());
return new ResponseEntity<>(fileByte, header, HttpStatus.OK);
}