ADD input and output downloaders
This commit is contained in:
@@ -8,9 +8,11 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/download")
|
||||
public class DownloadController {
|
||||
private final DownloadService downloadService;
|
||||
|
||||
@@ -19,9 +21,23 @@ public class DownloadController {
|
||||
this.downloadService = downloadService;
|
||||
}
|
||||
|
||||
@GetMapping("/download/{filename}")
|
||||
public ResponseEntity<Resource> downloadFile(@PathVariable String filename) {
|
||||
Resource resource = downloadService.downloadOutput(filename);
|
||||
@GetMapping("/output/{uuid}")
|
||||
public ResponseEntity<Resource> downloadFile(@PathVariable String uuid) {
|
||||
Resource resource = downloadService.downloadOutput(uuid);
|
||||
|
||||
if (resource == null || !resource.exists()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(resource);
|
||||
}
|
||||
|
||||
@GetMapping("/input/{uuid}")
|
||||
public ResponseEntity<Resource> downloadInput(@PathVariable String uuid) {
|
||||
Resource resource = downloadService.downloadInput(uuid);
|
||||
|
||||
if (resource == null || !resource.exists()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
|
||||
Reference in New Issue
Block a user