I have a controller hooked up to this method from a GET request:
def renderPNG() {
URL url = new URL("https://absolute.url.png");
BufferedImage img = ImageIO.read(url);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(img, "png", baos);
InputStream is = new ByteArrayInputStream(baos.toByteArray());
DataInputStream ds = new DataInputStream(is);
render file: ds, contentType: "image/png"
}
But when I get the image in the response, it is encoded with strange characters. How do I retrieve the image and decode is properly so it can be rendered by a browser?