|
|
@@ -129,7 +129,7 @@ public class DownloadController {
|
|
|
*/
|
|
|
@GetMapping(value="/download/document/{id}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
@ResponseBody
|
|
|
- public ResponseEntity<FileSystemResource> downloadDocument(@PathVariable("id") Integer idDocument, HttpServletResponse response) throws FileNotFoundException {
|
|
|
+ public ResponseEntity<byte[]> downloadDocument(@PathVariable("id") Integer idDocument, HttpServletResponse response) throws FileNotFoundException {
|
|
|
Document document = ds.findById(idDocument);
|
|
|
FileSystemResource file = new FileSystemResource(document.getRuta());
|
|
|
if(!file.exists()) {
|
|
|
@@ -137,7 +137,13 @@ public class DownloadController {
|
|
|
}
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+file.getFilename());
|
|
|
- return ResponseEntity.ok(file);
|
|
|
+ try {
|
|
|
+ return ResponseEntity.ok(file.getInputStream().readAllBytes());
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -150,7 +156,7 @@ public class DownloadController {
|
|
|
*/
|
|
|
@GetMapping(value="/download/report/{t}/{p}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
@ResponseBody
|
|
|
- public ResponseEntity<FileSystemResource> downloadReport(@PathVariable("t") Integer idTitulacio, @PathVariable("p") String nomProces,
|
|
|
+ public ResponseEntity<byte[]> downloadReport(@PathVariable("t") Integer idTitulacio, @PathVariable("p") String nomProces,
|
|
|
HttpServletResponse response) throws IOException, XDocReportException {
|
|
|
|
|
|
OrganTransferDTO titulacio = core.findOrganById("T", idTitulacio);
|
|
|
@@ -163,11 +169,11 @@ public class DownloadController {
|
|
|
if(it != null) {
|
|
|
if((new File(this.filePath+it.getEvidencia())).exists()) {
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+Integer.toString(idTitulacio)+"_"+nomProces+".pdf");
|
|
|
- return ResponseEntity.ok(new FileSystemResource(this.filePath+it.getEvidencia()));
|
|
|
+ return ResponseEntity.ok(new FileSystemResource(this.filePath+it.getEvidencia()).getInputStream().readAllBytes());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return ResponseEntity.ok(new FileSystemResource(this.filePath+it.getEvidencia()));
|
|
|
+ return ResponseEntity.ok(new FileSystemResource(this.filePath+it.getEvidencia()).getInputStream().readAllBytes());
|
|
|
}
|
|
|
|
|
|
|