1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//package br.com.treinaweb.twjobs.api.files;
//
//import lombok.RequiredArgsConstructor;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.io.FileSystemResource;
//import org.springframework.core.io.InputStreamResource;
//import org.springframework.core.io.Resource;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.File;
//import java.io.IOException;
//import java.nio.file.DirectoryStream;
//import java.nio.file.Files;
//import java.nio.file.Path;
//import java.util.logging.Level;
//import java.util.logging.Logger;
//import java.util.stream.Collectors;
//import java.util.stream.StreamSupport;
//
//@RestController
////@RequiredArgsConstructor
////@RequestMapping("/api/files")
//public class FilaManagerController {
//
// @Autowired
// private FileStorageService fileStorageService;
// private static final Logger log = Logger.getLogger(FilaManagerController.class.getName());
//
// @PostMapping("/upload-file")
// public boolean uploadFile(@RequestParam("file") MultipartFile file) {
// try {
// fileStorageService.saveFile(file);
// return true;
// } catch (IOException e) {
// log.log(Level.SEVERE, "Exception during upload", e);
// }
// return false;
// }
//
// @GetMapping("/download")
// public ResponseEntity<Resource> downloadFile(@RequestParam("fileName") String filename) {
// log.log(Level.INFO, "[NORMAL] Download with /download");
// try {
// var fileToDownload = fileStorageService.getDownloadFile(filename);
// return ResponseEntity.ok()
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
// .contentLength(fileToDownload.length())
// .contentType(MediaType.APPLICATION_OCTET_STREAM)
// .body(new InputStreamResource(Files.newInputStream(fileToDownload.toPath())));
// } catch (Exception e) {
// return ResponseEntity.notFound().build();
// }
// }
//
//
//
//
//
//
//
// @GetMapping("/download-faster")
// public ResponseEntity<Resource> downloadFileFaster(@RequestParam("fileName") String filename) {
// log.log(Level.INFO, "[FASTER] Download with /download-faster");
// try {
// var fileToDownload = fileStorageService.getDownloadFile(filename);
// return ResponseEntity.ok()
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
// .contentLength(fileToDownload.length())
// .contentType(MediaType.APPLICATION_OCTET_STREAM)
// .body(new FileSystemResource(fileToDownload));
// } catch (Exception e) {
// return ResponseEntity.notFound().build();
// }
// }
//
//}