Class FileController


  • @Controller
    @RequestMapping("material1/file")
    public class FileController
    extends java.lang.Object
    Controller Class for all requests on 'material1/file'.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String deleteFile​(org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token, long fileId)
      Deletes a file.
      org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> downloadFile​(org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token, long fileId)
      Downloads a file.
      java.lang.String renameFile​(org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token, long fileId, java.lang.String newName)
      Renames a file.
      org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> showFile​(org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token, long fileId)
      Retrieves a file preview.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileController

        public FileController​(FileService fileService)
    • Method Detail

      • showFile

        @GetMapping("/{fileId}")
        public org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> showFile​(org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token,
                                                                                                      @PathVariable("fileId")
                                                                                                      long fileId)
        Retrieves a file preview.
        Parameters:
        token - user credentials
        fileId - the id of the requested file
        Returns:
        in-browser preview of the file
      • downloadFile

        @ResponseBody
        @GetMapping("/{fileId}/download")
        public org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> downloadFile​(org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token,
                                                                                                          @PathVariable("fileId")
                                                                                                          long fileId)
        Downloads a file.
        Parameters:
        token - a keycloak authentication token
        fileId - the id of the requested file
        Returns:
        the route to template 'file'
      • deleteFile

        @PostMapping("/{fileId}/delete")
        public java.lang.String deleteFile​(org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes,
                                           org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token,
                                           @PathVariable("fileId")
                                           long fileId)
        Deletes a file.
        Parameters:
        redirectAttributes - redirect attributes
        token - keycloak auth token
        fileId - the id of the file to be deleted
        Returns:
        the route to the parentDir of the deleted file
      • renameFile

        @PostMapping("/{fileId}/rename")
        public java.lang.String renameFile​(org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes,
                                           org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken token,
                                           @PathVariable("fileId")
                                           long fileId,
                                           @RequestParam("newName")
                                           java.lang.String newName)
        Renames a file.
        Parameters:
        redirectAttributes - redirection attributes
        token - keyloak auth token
        fileId - the file id
        newName - the new name
        Returns:
        back to the overview