camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From crmanoj <>
Subject Using camel-servlet with Multipart - unable to fetch the file
Date Thu, 09 May 2013 01:22:47 GMT

I am trying to upload a file to the server from client using
multipart/form-data. The server endpoint is a camel-servlet endpoint. I am
able to get the httprequestbody from the call using (in.headers), to parse
the form data and uploaded file data i'm using commons-fileupload( streaming
api <>  )
library. Though the request is a multipart, I am unable to get the fileitems
from the function call. Here is the codesnippet used to get the item
(iter.hasNext() always returns false).

HttpServletRequest request = (HttpServletRequest)

// Check if the request is actually a multipart/form-data request."IS Mulipart: " + ServletFileUpload.isMultipartContent(request));
if (!ServletFileUpload.isMultipartContent(request))
     return "No Data found";
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(request);"iter has next: " + iter.hasNext());

My Camel route looks like below:


My camel Servlet component definition goes as below:

 <service ref="camelServlet">
            <entry key="alias" value="/camel/services" />
            <entry key="matchOnUriPrefix" value="true" />
            <entry key="servlet-name" value="CamelServlet"/>

<osgi:reference id="servletref"
    <osgi:listener bind-method="register" unbind-method="unregister">
	<ref bean="httpRegistry" />

<bean id="httpRegistry"
<bean id="servlet"
	<property name="httpRegistry" ref="httpRegistry" />

This project is run in fuse-esb-7.1.0.fuse-047 using camel version: 2.9.
JDK: 1.6.

Could anyone guide me to separate the form parameters and file data using
servlet endpoint?

Thanks in Advance!

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message