cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <coc...@lojjic.net>
Subject Re: How to send a "mime-type: image/jpeg" response generated from a BufferedImage
Date Fri, 14 Jul 2006 03:44:59 GMT
Christian Sengstock wrote:
> Hello list,
> 
> in my application i generate dynamically a BufferedImage object and i
> want to complete the pipeline with sending the image as a "mime-type:
> image/jpeg" response.
> 
> At the moment i have a matcher which takes the request and calls a
> flowScript function which in turn handles the dynamic creation of the
> BufferedImage. Afterwards i save the image to disk and send the URI of
> the image-file via the cocoon.sendPage( <filename.jpeg> ) function to
> the sitemap, where a reader handles the proper response as a mime-type
> image/jpeg.
> 
> This is working for me but i thought that there might be a better
> approach to do this. Maybe without saving the BufferedImage to disk.
> 
> Can anybody give me a hint how to create a "mime-type: image" response
> out of a BufferedImage? Maybe it's possible by extending a reader or
> by using a serializer?


If you can get the content of your BufferedImage as an InputStream or 
byte[] array (sorry I don't know that API), then you can pass it along 
as view data in sendPage(), and serve it up with the standard 
ResourceReader and the ModuleSource:


=== flowscript: ===

var imageInputStream = ...
cocoon.sendPage("image-pipeline", {imageInputStream:imageInputStream});


==== sitemap: ===

<map:match pattern="image-pipeline">
   <map:read src="module:flow-attr:imageInputStream"
             mime-type="image/jpeg" />
</map:match>


--Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message