On Mon, Aug 16, 2010 at 12:07 PM, Tauren Mills <tauren_at_groovee.com> wrote:
> I just posted a Jersey related question on StackOverflow and then
> realized I'd be better off sending it here instead. But if you wish to
> answer it, the question is here:
> http://stackoverflow.com/questions/3496209/input-and-output-binary-streams-using-jersey
>
> I'm using Jersey to implement a RESTful API that is primarily retrieve
> and serve JSON encoded data. But I have some situations where I need
> to accomplish the following:
>
> * Export downloadable documents, such as PDF, XLS, ZIP, or other binary files.
I think easiest way would be to just return byte[], or if you don't
want to read and buffer, create StreamingOutput instance that reads
file (etc) and writes content directly to output.
For input, one alternative to multi-part could be using Jackson's
base64 support, assuming client could do base64 encoding. It is
reasonably efficient for processing so should work ok for moderate
file sizes (in megabytes at least).
-+ Tatu +-