[xwiki-users] Return image in http response
Hi all, I have some groovy page generating an image (BufferedImage), and I would like it to be returned and displayed in browser. I first tried to save this image as a png file with ImageIO, and it works pretty well and image can be displayed. If then I try to return it in http response, it always return "The image "http://localhost/...." cannot be displayed because it contains errors". {{velocity}} {{groovy}} [...] $context.response.setContentType("image/png"); OutputStream os = $context.response.getOutputStream(); ImageIO.write(image, "jpg", os); os.close(); [...] {{/groovy}} {{/velocity}} Strangely, if I remove this previous code from my page to put back the png file saving, png file is saved but error message still shows up ... (cache ?) I'm asking this question here because maybe it's not the better way to achieve this with XWiki ... Thx for any help -- View this message in context: http://n2.nabble.com/Return-image-in-http-response-tp3075088p3075088.html Sent from the XWiki- Users mailing list archive at Nabble.com.
I tried to attach the image file back into the page, but if I call $xwiki.getDocument(...).addAttachment(...) it fails, as well as if I call xwiki.getDocument(...).addAttachment(...), saying it does not know the property "xwiki". By the way my groovy scripts in syntax 1.0, migrated to 2.0, complain about non existing property "xwiki" ... Am I missing something ? -- View this message in context: http://n2.nabble.com/Return-image-in-http-response-tp3075088p3075261.html Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (1)
-
jerem