@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";
   }
 }
  @RequestMapping(value = "/", method = RequestMethod.POST)
  public String uploadFile(
      @Valid UploadFormModel uploadFormModel, Model model, BindingResult bindingResult)
      throws Exception {
    if (bindingResult.hasErrors()) {
      return "upload";
    } else if (uploadFormModel.getFile().isEmpty()) {
      bindingResult.addError(new ObjectError("file", "No file specified"));
      return "upload";
    } else {
      MultipartFile file = uploadFormModel.getFile();
      String publicId =
          managementService.upload(
              file.getInputStream(),
              file.getOriginalFilename(),
              file.getContentType(),
              file.getSize(),
              uploadFormModel.getPassword());

      model.addAttribute("publicId", publicId);
      return "success";
    }
  }