I have repository class where I want to store the image that is coming from MultipartFile to webapp/resources/images directory before adding the product details to the repository ?
@Override
public void addProduct(Product product) {
Resource resource = resourceLoader.getResource("file:webapp/resources/images");
MultipartFile proudctImage = product.getProudctImage();
try {
proudctImage.transferTo(new File(resource.getFile()+proudctImage.getOriginalFilename()));
} catch (IOException e) {
throw new RuntimeException(e);
}
listOfProducts.add(product);
}
my repository class is ResourceLoaderAware. I am getting fileNotFoundException, "imagesDesert.jpg" is the image I am trying to upload
java.io.FileNotFoundException: webapp\resources\imagesDesert.jpg (The system cannot find the path specified)