How to return image as stream from JAX-RS?
cxf, jackson, jax-rs
Solution
Just use `StreamingOutput` wrapper. For some reason it is unknown, but it is GREAT for providing, well, streaming output. :-)
Problem
I'm trying to return an image in a JAX-RS web service. I was able to get this successfully working by returning `FileInputStream` but I'd prefer to avoid creating a `File` for each request. I am using Apache CXF and Jackson (all the other resource methods produce application/json). Code looks like this: ``` @GET @Produces("image/png") public Response getQrCode(@QueryParam("qrtext") String qrtext) { ByteArrayOutputStream out = QRCode.from(qrtext).to(ImageType.PNG).stream(); return Response.ok(out).build(); } ``` Unfortunately, this produces the dreaded: org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor:376 - No message body writer has been found for response class ByteArrayOutputStream. Here's a link to a similar post but it doesn't mention the "No message body writer" issue I'm running into. I'd appreciate any ideas of how to deal with this issue. Thanks!