Re: Using camel-servlet with Multipart - unable to fetch the file

2013-05-14 Thread Willem jiang
camel will try to digest the HttpServletRequest and setup the message headers 
and body.
It's a common practice to consume the input stream from message body :)  


--  
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 Wednesday, May 15, 2013 at 4:47 AM, crmanoj wrote:

> This is resolved by using/parsing the input stream from camel body instead of
> using the HttpServletRequest from camel Headers.
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Using-camel-servlet-with-Multipart-unable-to-fetch-the-file-tp5732204p5732534.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).





Re: Using camel-servlet with Multipart - unable to fetch the file

2013-05-14 Thread crmanoj
This is resolved by using/parsing the input stream from camel body instead of
using the HttpServletRequest from camel Headers.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-camel-servlet-with-Multipart-unable-to-fetch-the-file-tp5732204p5732534.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using camel-servlet with Multipart - unable to fetch the file

2013-05-09 Thread crmanoj
I'm using the OSGI service for camel servlet and I do not want to use
camel-jetty as it takes its own port instead of existing jetty server port.
What strange is I can see the contents of the multipart data from request if
I parse them manually, But I am unable to separate the form fields and file
data. Could you give some suggestions for this scenario?

Thanks!





--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-camel-servlet-with-Multipart-unable-to-fetch-the-file-tp5732204p5732232.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using camel-servlet with Multipart - unable to fetch the file

2013-05-08 Thread Willem jiang
camel-jetty is using org.eclipse.jetty.servlets.MultiPartFilter to handle this 
multipart message.
You may consider to configure the filter in your web.xml.


--  
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, May 9, 2013 at 2:35 PM, crmanoj wrote:

> Thank you for replying! I have tried removing them but no difference. Am I
> using the component correctly? Is there any other way to get the form fields
> and data separetely? I have tried camel-jetty component and it separates the
> form fields and data, Is there anything similar to that in camel-servlet?
>  
> Thank you!
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Using-camel-servlet-with-Multipart-unable-to-fetch-the-file-tp5732204p5732211.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).





Re: Using camel-servlet with Multipart - unable to fetch the file

2013-05-08 Thread crmanoj
Thank you for replying! I have tried removing them but no difference. Am I
using the component correctly? Is there any other way to get the form fields
and data separetely? I have tried camel-jetty component and it separates the
form fields and data, Is there anything similar to that in camel-servlet?

Thank you!



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-camel-servlet-with-Multipart-unable-to-fetch-the-file-tp5732204p5732211.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using camel-servlet with Multipart - unable to fetch the file

2013-05-08 Thread Willem jiang
Hi  

I suggest you remove the streamCaching() and to("log:servlet") from your route.
Current streamCaching doesn't support to caching the Servlet request input 
stream.


--  
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, May 9, 2013 at 9:22 AM, crmanoj wrote:

> Hi,
>  
> 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 <http://commons.apache.org/proper/commons-fileupload/streaming.html> )
> 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)
> headers.get(Exchange.HTTP_SERVLET_REQUEST);
>  
> // Check if the request is actually a multipart/form-data request.
> LOG.info (http://LOG.info)("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);
> LOG.info (http://LOG.info)("iter has next: " + iter.hasNext());
>  
> My Camel route looks like below:
>  
> from("servlet:///addContent").streamCaching()
> .to("log:servlet").beanRef("sampleProcessor");
>  
> My camel Servlet component definition goes as below:
>  
> 
> 
> javax.servlet.Servlet
> org.apache.camel.component.http.CamelServlet
> 
> 
> 
> 
> 
> 
> 
>  
>  interface="org.apache.camel.component.http.CamelServlet">
> 
> 
> 
> 
>  
>  class="org.apache.camel.component.servlet.DefaultHttpRegistry">
> 
>  class="org.apache.camel.component.servlet.ServletComponent">
> 
> 
>  
> 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: 
> http://camel.465427.n5.nabble.com/Using-camel-servlet-with-Multipart-unable-to-fetch-the-file-tp5732204.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).





Using camel-servlet with Multipart - unable to fetch the file

2013-05-08 Thread crmanoj
Hi,

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 <http://commons.apache.org/proper/commons-fileupload/streaming.html>  )
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)
headers.get(Exchange.HTTP_SERVLET_REQUEST);

// Check if the request is actually a multipart/form-data request.
LOG.info("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);
LOG.info("iter has next: " + iter.hasNext());

My Camel route looks like below:

from("servlet:///addContent").streamCaching()
.to("log:servlet").beanRef("sampleProcessor");

My camel Servlet component definition goes as below:

 

javax.servlet.Servlet
org.apache.camel.component.http.CamelServlet




















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: 
http://camel.465427.n5.nabble.com/Using-camel-servlet-with-Multipart-unable-to-fetch-the-file-tp5732204.html
Sent from the Camel - Users mailing list archive at Nabble.com.