Package mops.presentation
Class FileController
- java.lang.Object
-
- mops.presentation.FileController
-
@Controller @RequestMapping("material1/file") public class FileController extends java.lang.Object
Controller Class for all requests on 'material1/file'.
-
-
Constructor Summary
Constructors Constructor Description FileController(FileService fileService)
-
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.
-
-
-
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 credentialsfileId
- 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 tokenfileId
- 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 attributestoken
- keycloak auth tokenfileId
- 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 attributestoken
- keyloak auth tokenfileId
- the file idnewName
- the new name- Returns:
- back to the overview
-
-