@RequestMapping(value = "/{publicId:[a-z0-9]{16}}", method = RequestMethod.POST) public String download( @PathVariable String publicId, @RequestParam(required = false) String password, Model model, HttpServletResponse response) throws Exception { try { FileDownload fileDownload = managementService.download(publicId, password); httpResponseUtil.writeFile( response, fileDownload.getStream(), fileDownload.getFileName(), fileDownload.getFileType(), (int) fileDownload.getFileSize()); return null; } catch (InvalidPasswordException e) { FileInfo fileInfo = managementService.info(publicId); model.addAttribute("file", fileInfo); model.addAttribute("pwError", true); return "download"; } catch (LinkExpiredException e) { return "expired"; } }
@RequestMapping(value = "/{publicId:[a-z0-9]{16}}", method = RequestMethod.GET) public String showDownload(@PathVariable String publicId, Model model) { try { FileInfo fileInfo = managementService.info(publicId); model.addAttribute("file", fileInfo); return "download"; } catch (LinkExpiredException e) { return "expired"; } }