I have this endpoint:
@GetMapping("/thumbnail/{imageName}")
@PreAuthorize("hasRole('BASIC')")
public ResponseEntity<InputStreamResource> natalChartThumbnail() throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
// 🔹 Generate thumbnail
BufferedImage bufferedImage = Thumbnails.of(new File("/usr/local/bin/tmp/scaled_sun_in_cancer_moon_in_aquarius.jpg"))
.scale(1.0)
.asBufferedImage();
ImageIO.write(bufferedImage, "jpg", os);
InputStream is = new ByteArrayInputStream(os.toByteArray());
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("image/jpg"))
.body(new InputStreamResource(is));
}
But in Postman, I see this:
and imageExtension: jpg
I also tried with:
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("image/jpeg"))
.body(new InputStreamResource(is));
with the same result




image/jpegis equivalent to the answer that suggests setting theproducesattribute of the@GetMappingannotation. Are you sure it didn't work? As ^^ Olivier asks, what did you receive as acontent-typeresponse header?MediaTypeconstant for it already, inMediaType.IMAGE_JPEG.producesorcontentTypeleads to the same result. The issue persisted even after applying Olivier’s suggestion due to Postman caching. I've managed to reproduce it. And I guess you can as well