users@jersey.java.net

How to stream MIME multipart content without hitting disk?

From: <Buccola_David_at_emc.com>
Date: Tue, 26 May 2009 19:11:53 -0400

I'm trying to perform efficient streaming of potentially large multipart
data. I don't want to hit disk. I noticed in the 1.0.3 release notes the
following reference:

        "The parsing of Multipart MIME now uses the MIMEPull API which
provides efficient stream-based processing"

I can't figure out how to use streaming yet. I have a method declared
something like this:

    @POST
    @Consumes("multipart/mixed")
    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public Response postObjectWithContent (@Context HttpHeaders headers,
MultiPart multiPart) throws Exception


I've found that that MultiPartReader that gets invoked to service this
request seems to parse the entire MIME message up front because of the
call to MIMEMessage.getAttachments().

What am I doing wrong? What do I need to do in order to get stream-based
access to MIME parts without preparsing and copying them to disk?

- Dave Buccola