Пример #1
0
 @RequestMapping(value = "/profile", params = "upload", method = RequestMethod.POST)
 public String onUpload(MultipartFile file, RedirectAttributes redirectAttrs, Model model)
     throws IOException {
   if (file.isEmpty() || !isImage(file)) {
     // throw new IOException("Incorrect file.Please upload a picture.");
     redirectAttrs.addFlashAttribute("error", "Incorrect file.Please upload a picture.");
     return "redirect:/profile";
   }
   // copyFileToPictures(file);
   Resource picturePath = copyFileToPictures(file);
   // model.addAttribute("picturePath", picturePath.getFile().toPath());
   userProfileSession.setPicturePath(picturePath);
   return "redirect:/profile";
 }