Camel Jetty component is using the org.eclipse.jetty.servlets.MultiPartFilter 
by default.
You can access the file from the message attachment just like this

Message in = exchange.getIn();  
assertEquals("Get a wrong attachement size", 1, in.getAttachments().size());
// The file name is attachment id
DataHandler data = in.getAttachment("image");

Then you should get the input stream from the data handler.  

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, April 18, 2013 at 5:52 AM, Calvert, Zach (Zach)** CTR ** wrote:

> I'm having trouble submitting a multi-part form to a CXF endpoint. My route 
> looks like:
> <camel:route id="submitform">
> <camel:from uri="jetty:https://0.0.0.0:9005/submit/?matchOnUriPrefix=true"/>
> <camel:log message="Request received" loggingLevel="DEBUG"/>
> <camel:to uri="cxfbean:consumerList"/>
> </camel:route>
> Where the list is a util list of 1 endpoint consuming a POST method. The HTML 
> form code is retrieved from the same path using a GET, resulting in:
>  
> <html>
> <body>
> <form enctype='multipart/form-data' method='post' action='/submit'>
> <INPUT type='text' id='firstname'>
> <BR>
> <input type='file' name='image'>
> <BR>
> <input type='submit' value='Send'>
> </form>
> </body>
> </html>
>  
> Submitting a post triggers this in the logs:
> 2013-04-17 15:55:40,900 | WARN | qtp11314826-356 | 
> WebApplicationExceptionMapper | - - | WebApplicationException has been caught 
> : Couldn't find MIME boundary: -----------------------------173102388111750
>  
> I walked the code to org.apache.cxf.attachment.AttachmentDeserializer
> Where it obtains the "InputStream" content body using:
> ...
> boundary = boundaryString.getBytes("utf-8");
>  
> stream = new PushbackInputStream(message.getContent(InputStream.class),
> pbAmount);
> ...
>  
> The resulting InputStream from the CXF Message, while non-null, always 
> returns -1 at the first read. In other words, this InputStream is empty 100% 
> of the time. I've verified using different browsers that the content is 
> submitted, and the MIME boundary is populated in the content. What is going 
> on with the input stream? Have I configured my CXF endpoint incorrectly in 
> some way, or am I missing a configuration detail in the form?
>  
> Any and all help is greatly appreciated!
>  
>  
> Thank you,
> Zach Calvert



Reply via email to