0

I am using http://commons.apache.org/proper/commons-fileupload/ to parse multipart form and extract an uploaded file. I am following this manual http://www.oreillynet.com/onjava/blog/2006/06/parsing_formdata_multiparts.html and fresh new documentation from inside that package. The request.getContentLength() is saying 700K and that is the code

InputStream input = request.getInputStream();
MultipartStream mStream = new MultipartStream(input, boundArray, 94096 /*random number*/, null);
boolean part = mStream.skipPreamble();

And the part is always false. Could anybody tell me why? Thank you!

1 Answers1

0

Regarding to code of MultipartStream.java you get MalformedStreamException in discardBodyData or readBoundary.

Looks like discardBodyData only declares that, bun never throws MalformedStreamException.

readBoundary throws MalformedStreamException("Unexpected characters follow a boundary") and MalformedStreamException("Stream ended unexpectedly").

Comment says:

* @throws MalformedStreamException if the stream ends unexpectedly or
*                                  fails to follow required syntax

Hypothesis: 94096 /random number/ is supposed to be buffer size. 94096 is not enough for 700K, so for MultipartStream stream ends unexpectedly.

Nikolay
  • 81
  • 3