Hi,

Restlet uses the Representation to define the message and mediate type[1].
Camel-Restlet doesn't support the Representation well, and it just try to turn 
the bytes into String as a fall back.
I just fill a JIRA[2] for it and will commit the fix shortly.

You can work around it by changing the message body into an InputStream and set 
Content-Type on the message header.  

[1]http://stackoverflow.com/questions/1509873/serve-dynamic-generated-images-using-restlet
  
[2]https://issues.apache.org/jira/browse/CAMEL-6834
--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Tuesday, October 8, 2013 at 6:29 AM, Zemin Hu wrote:

> I need to return image from route in restlet environment, if in normal camel
> environment I should be able to do
> byte[] imageData = getImage();
> HttpServletResponse response =
> exchange.getIn().getBody(HttpServletResponse.class);
> response.setContentType("image/png");
> OutputStream os = response.getOutputStream();
> os.write(imageData);
> os.close();
> Now, in restlet environment, the response is null. I am doing:
> exchange.getOut().setBody(imageData);
> While it executed correctly, the data is encoded and inflated(about 30-40%
> more), the header is set to:
> Content-Type: text/plain;charset=UTF-8
> if I don't set "Content-Type", but even I set it to original type:
> "image/png", the header will be
> Content-Type: image/pgn;charset=UTF-8
> The returning binary data is still inflated and encoded.  
> Is there any way to prevent this to happen? I guess my another question
> would be:
> How do I get HttpServletResponse or OutputStream for response in restlet
> environment so I can simply set up and output my binary data as in normal
> servlet environment? Where is it hidden(I tried to find it under debugging
> environment but could not find it)?
> Thanks.
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/return-binary-image-data-in-camel-restlet-environment-tp5741062.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).



Reply via email to