Skip to content

Commit

Permalink
broken images refuse to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ktali committed Nov 18, 2018
1 parent 76ccfd8 commit 3a10497
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/kmk/imageboard/service/ImageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.springframework.web.multipart.MultipartFile;

import javax.imageio.IIOException;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -53,7 +54,12 @@ public ResponseEntity<String> uploadImage(Principal principal, MultipartFile fil
Scalr.Mode.AUTOMATIC,
128,
128);
ImageIO.write(thumbnailBufferedImage, "jpg", new File("imagerepository" + File.separator + "thumbnails" + File.separator + newEntity.getId()));
try {
ImageIO.write(thumbnailBufferedImage, "jpg", new File("imagerepository" + File.separator + "thumbnails" + File.separator + newEntity.getId()));
} catch (IIOException e) {
imageRepository.delete(newEntity);
throw e;
}
bufferedImage.flush();
thumbnailBufferedImage.flush();

Expand Down

0 comments on commit 3a10497

Please sign in to comment.