简体   繁体   English

为什么skipPreamble()返回false?

[英]Why the skipPreamble() return false?

I am using http://commons.apache.org/proper/commons-fileupload/ to parse multipart form and extract an uploaded file. 我正在使用http://commons.apache.org/proper/commons-fileupload/解析多部分表单并提取上载的文件。 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. 我正在遵循该手册http://www.oreillynet.com/onjava/blog/2006/06/parsing_formdata_multiparts.html和该软件包内部的新文档。 The request.getContentLength() is saying 700K and that is the code request.getContentLength()说700K,这就是代码

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! 谢谢!

Regarding to code of MultipartStream.java you get MalformedStreamException in discardBodyData or readBoundary. 关于MultipartStream.java的代码,您会在discardBodyData或readBoundary中获得MalformedStreamException。

Looks like discardBodyData only declares that, bun never throws MalformedStreamException. 看起来,discardBodyData只声明了,bun从不抛出MalformedStreamException。

readBoundary throws MalformedStreamException("Unexpected characters follow a boundary") and MalformedStreamException("Stream ended unexpectedly"). readBoundary抛出MalformedStreamException(“意外字符跟随边界”)和MalformedStreamException(“ Stream意外结束”)。

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 / 随机数 /应该是缓冲区大小。 94096 is not enough for 700K, so for MultipartStream stream ends unexpectedly. 94096不足以容纳700K,因此对于MultipartStream流意外结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM