Hi,
I’m having a problem getting a multipart-mime uploaded file from the servlet
component using Commons FileUpload.
I’m using Camel 2.12.2 with Tomcat 7.04 using the camel-example-servlet-tomcat
with added groovy.
What happens is I can parse the stream and get the headers, but the body seems
to be empty i.e. boolean nextPart = multipartStream.skipPreamble(); always
returns false.
Any ideas? My groovy code is below less the imports.
def mybody =
exchange.getIn().getBody(InputStream.class);
def content_type =
exchange.getIn().getHeader(exchange.CONTENT_TYPE,String.class);
//Get the mime boundary string
int lastIndex = content_type.lastIndexOf("=");
String boundary = content_type.substring(lastIndex+1,
content_type.length());
//Send the stream and the boundary to the parser
MultipartStream multipartStream = new
MultipartStream(mybody, boundary.getBytes());
response = "Headers. " + multipartStream.readHeaders();
boolean nextPart = multipartStream.skipPreamble();
response += “ Is there a next part? “ + nextPart ;
while(nextPart) {
// Do something here
nextPart = multipartStream.readBoundary();
}
response;
I’ve tried this with both caching on and off without any success.
Rgds,
Mark Lawson
Senior Technical Architect
Staffordshire and West Midlands Probation Trust
[sent from home email]