users@jersey.java.net

Re: [Jersey] caching binary stream data

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Fri, 17 Sep 2010 07:51:29 -0700

On Sep 15, 2010, at 6:39 PM, jameskpublic wrote:

>
> I have a multi-part message with many of the parts being binary data.
> I will eventually flush the the binary data to a database, but I'm
> concerned
> about the memory footprint of the request.
> Do large multi-part mime parts data get cached to disk, and if so,
> does it
> automatically get cleaned up?

Yes. Once the request goes out of scope any body parts temporarily
cached to disk will be removed.


> If it's cached to disk, does the framework support multiple reads of
> the
> data?
> I understand that i can get a reference to an InputStream which will
> allow
> me to read it once, but what if I want to read it twice?
>

It should work, but only when the request is in scope.

Jersey's MIME multipart support uses a library called MIMEPull that
supports caching and reading parts more than once.

Paul.