Mam taką metodę
@RequestMapping(value = "/customers/add", method = RequestMethod.POST)
public String processAddCustomerForm(@Valid @ModelAttribute("customer") Customer customer, BindingResult result, HttpServletRequest request) {
MultipartFile customerImage = customer.getImage();
String rootDirectory = request.getSession().getServletContext().getRealPath("/");
System.out.println(rootDirectory);
if(result.hasErrors()){
return "add";
}
else {
int rowAffected = repository.addCustomer(customer);
if (customerImage!=null && !customerImage.isEmpty()) {
try {
customerImage.transferTo(new File(rootDirectory+"resources\\images\\"+rowAffected + ".jpg"));
System.out.println("success");
} catch (Exception e) {
throw new RuntimeException("Product Image saving failed", e);
}
}
return "redirect:/customers";
}
}
Ładuje mi ona pliki do C:\apache-tomcat-7.0.69-windows-x64\apache-tomcat-7.0.69\webapps\ROOT\ +"resources\images\"+rowAffected + ".jpg"
Wszystko bangla ładnie pięknie do czasy jak nie zresetuję servera po dokonaniu zmian w kodzie(Apache Tomcat). Wtedy nagle wszystko co załaduję do tego folderu znika z niego. Jak to naprawić?