コード例 #1
0
  @RequestMapping(value = IMAGES + "/{fileName}.{fileType}")
  public void getImage(
      @PathVariable String fileName,
      @PathVariable String fileType,
      @RequestParam(required = false) String version,
      HttpServletResponse response)
      throws IOException {

    FileImageFinder.FileInfo file = imageFinder.getFile(fileName + "." + fileType, version);

    response.setContentType(MediaType.parseMediaType("image/" + fileType).toString());
    response.setContentLength(file.bytes.length);
    response.setHeader("Last-Modified", file.modifyTime);
    response.setHeader("Cache-Control", "public, max-age=3153600");
    response.getOutputStream().write(file.bytes);
  }
コード例 #2
0
  @RequestMapping(value = IMAGES, method = POST)
  public String addImage(
      @RequestParam("image") MultipartFile file,
      DefaultMultipartHttpServletRequest request,
      Locale locale)
      throws IOException {

    // NOTE: Checking user rights and CSRF-Token needs to be done here because HttpUserService gains
    // NOTE org.eclipse.jetty.server.Request which is not able to handle parameters at
    // multipartrequests

    User currentUser = userService.getCurrentUser(false);
    if (!currentUser.isOm()) {
      throw new AccessDeniedException("Om rights required");
    }

    userService.verifyCSRFToken(request);

    imageFinder.validateAndSaveFile(file);
    return redirectWithMessage(
        request.getHeader("Referer"), RequestMessage.EDITOR_UPLOAD_IMAGE, request);
  }
コード例 #3
0
 @RequestMapping(value = IMAGE_JSON, produces = JSON)
 public @ResponseBody List<FileImageFinder.FileJson> files() {
   return imageFinder.getImages();
 }