Skip to content

Commit 1f36933

Browse files
fix: malformed file path
there was missing a '/' when uploading a new image to the upload folder
1 parent 332332c commit 1f36933

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/main/java/com/vianavitor/simplelibrarygame/service/BookService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ public Book changeImage(Long id, MultipartFile file) throws ResourceNotFoundExce
104104
Book book = repository.findById(id)
105105
.orElseThrow(() -> new ResourceNotFoundException("not found book"));
106106

107-
File absolutePath = new File(imagePath + "/");
107+
File absolutePath = new File(imagePath);
108108
File destination = getFile(file, absolutePath, book);
109109
file.transferTo(destination);
110110

111-
System.out.println(destination.getAbsolutePath());
111+
// System.out.println(destination.getAbsolutePath());
112112

113113
book.setImagePath(destination.getAbsolutePath());
114114
return repository.save(book);
@@ -138,7 +138,7 @@ public Book changeImage(Long id, MultipartFile file) throws ResourceNotFoundExce
138138
throw new UnsupportedFileTypeException("unsupported image type: " + extension);
139139
}
140140

141-
return new File(directory + book.getId().toString() + "." + extension);
141+
return new File(directory + "/" + book.getId().toString() + "." + extension);
142142
}
143143

144144
public void rate(Long id, int rate) throws ResourceNotFoundException{

0 commit comments

Comments
 (0)