Browse Source

Arreglada la descarga de ficheros

Mario Martínez Hernández 4 weeks ago
parent
commit
39bed7abb4
1 changed files with 3 additions and 5 deletions
  1. 3 5
      src/main/java/es/uv/saic/web/DownloadController.java

+ 3 - 5
src/main/java/es/uv/saic/web/DownloadController.java

@@ -100,7 +100,7 @@ public class DownloadController {
 	 */
 	@GetMapping(value="/download/{fileName}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
 	@ResponseBody
-	public byte[] download(@PathVariable("fileName") BigInteger idInstanciaTasca, HttpServletResponse response) throws FileNotFoundException {		
+	public ResponseEntity<byte[]> download(@PathVariable("fileName") BigInteger idInstanciaTasca, HttpServletResponse response) throws FileNotFoundException {		
 		
 		try {
 			InstanciaTascaDTO i = findByIdTasca(idInstanciaTasca);
@@ -113,16 +113,14 @@ public class DownloadController {
 			}
 			else{
 				file = new FileSystemResource(this.filePath+i.getEvidencia());
-				System.out.println(i.getEvidencia()+".zip");
 				response.setHeader("Content-Disposition", "attachment; filename="+i.getEvidencia());
 			}
 			
 			if (!file.exists()) {
-				return new FileSystemResource(this.fileNotFound).getInputStream().readAllBytes();
+				return ResponseEntity.ok(new FileSystemResource(this.fileNotFound).getInputStream().readAllBytes());
 			}
 
-			response.setContentType("application/zip");
-			return file.getInputStream().readAllBytes();
+			return ResponseEntity.ok(file.getInputStream().readAllBytes());
 		} catch (IOException e) {
 			e.printStackTrace();
 		}