I had a resource supporting GET with application/pdf implemented using
OutputRepresentation that was working in 2.0.mumble with the internal
connector. Using 2.1-M2, though, the internal connector only sends the first
250 bytes or so of about 4500 bytes total.

The code looked like this:

    final ByteArrayOutputStream bytes = ...;
    // generate PDF into bytes
    bytes.flush(); // didn't make any difference whether I flushed it or not
    return new OutputRepresentation(MediaType.APPLICATION_PDF, bytes.size())
{
        public void write(OutputStream os) {
            bytes.writeTo(os);
        }
    });

When I switched to returning InputStream, as in the POST discussion below,
it works fine.

I'll continue to use InputStream, but why would OutputRepresentation's
behavior suddenly change?

--tim


On Fri, Jul 2, 2010 at 11:50 AM, Jerome Louvel <[email protected]>wrote:

> Your annotated method could look like:
>
> @Post("xml:pdf")
> public InputStream submit(Document)
>
> If you can't return an InputStream, then you need to return
> an OutputRepresentation, overriding its write(OutputStream) method.
>
> @Post("xml:pdf")
> public OutputRepresentation submit(Document)
>
> Best regards,
> Jerome Louvel
>
> -----Message d'origine-----
> De : HT [mailto:[email protected]]
>
> Is there somewhere an example of how to send back a byte stream to
> the outputstream ?
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2695386

Reply via email to