Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

java - Corrupt form data: premature ending

I am trying to upload files using the FileReference class. Files >2MB all work correctly but files <2MB cause this error:

"java.io.IOException: Corrupt form data: premature ending"

On the server I am using the com.oreilly.servlet package to handle the request.

I have used this package many times to successfully handle file uploads from flex, but for some reason, now I am having this problem.

Here is the stack trace for some more info:

java.io.IOException: Corrupt form data: premature ending
    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:205)
    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:222)
    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:173)
    at com.mydomain.FileUploadServlet.doPost(FileUploadServlet.java:46)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:414)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

http://www.servlets.com/cos/faq.html

Why when using com.oreilly.servlet.MultipartRequest or MultipartParser do large uploads fail? The classes themselves were specifically designed to have no maximum upload size limit (unlike most other file upload utilities), but for your server's protection the constructor allows you to set a maximum POST size to accept. Any upload larger than the limit is halted. The default maximum is 1 Meg. For a discussion of the difficulties a server has in notifying a client of the error, see the discussion in Java Servlet Programming, 2nd Edition, page 119.

So, did you specify the maximum POST size to accept?

P.S. Ok, now I see that it's small uploads that cause the problem. On the FAQ link above there is a section dedicated to troubleshooting uploads, including some helful methods to isolate the cause (client, browser, web-server, libraries). Try them.

Install a Firefox plugin (Tamper Data or Firebug) that shows the request sent to server. May help you to understand if anything is different between <2M and >2M uploads.

P.P.S. Are the files of the same structure? Could it be that smaller ones have different data (e.g. special symbols) that break Flash library? Try to upload small files of spaces only, for instance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...