Class FileDownloadController

java.lang.Object
tech.ailef.dbadmin.external.controller.FileDownloadController

@Controller @RequestMapping({"/${dbadmin.baseUrl}/download","/${dbadmin.baseUrl}/download/"}) public class FileDownloadController extends Object
Controller to serve file or images (`@DisplayImage`)
  • Constructor Details

    • FileDownloadController

      public FileDownloadController()
  • 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: