Class DownloadController
java.lang.Object
tech.ailef.dbadmin.external.controller.DownloadController
@Controller
@RequestMapping({"/${dbadmin.baseUrl}/download","/${dbadmin.baseUrl}/download/"})
public class DownloadController
extends Object
Controller to serve file or images (`@DisplayImage`)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<byte[]>
Serve a binary field as a file.org.springframework.http.ResponseEntity<byte[]>
serveImage
(String className, String fieldName, String id) Serve a binary field as an image
-
Constructor Details
-
DownloadController
public DownloadController()
-
-
Method Details
-
serveImage
@GetMapping(value="/{className}/{fieldName}/{id}/image", produces="image/jpeg") @ResponseBody public org.springframework.http.ResponseEntity<byte[]> serveImage(@PathVariable String className, @PathVariable String fieldName, @PathVariable String id) Serve a binary field as an image- Parameters:
className
-fieldName
-id
-- Returns:
-
serveFile
@GetMapping("/{className}/{fieldName}/{id}") @ResponseBody public org.springframework.http.ResponseEntity<byte[]> serveFile(@PathVariable String className, @PathVariable String fieldName, @PathVariable String id) Serve a binary field as a file. This tries to detect the file type using Tika in order to serve the file with a plausible extension, since we don't have any meta-data about what was originally uploaded and it is not feasible to store it (it could be modified on another end and we wouldn't be aware of it).- Parameters:
className
-fieldName
-id
-- Returns:
-