上传大文件时FileUploadBase UnknownSizeException

时间:2014-07-15 09:58:16

标签: file-upload cxf struts-1 apache-commons-fileupload

我正在尝试使用struts1.2form文件和apache.commons.fileupload 1.0上传一个巨大的文件大小[超过5 GB]。我看到struts1中文件上传的最大限制是256M。有没有办法改变这个? 我得到以下例外。

 org.apache.commons.fileupload.FileUploadBase$UnknownSizeException: the request was rejected because its size is unknown
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:305)
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
        at org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(CommonsMultipartRequestHandler.java:182)
        at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:389)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:191)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:745) 

默认文件大小限制为250MB。我增加到350MB。它工作正常。 之后我将它增加到10G并获得以下异常。 是否可以使用struts1.2上传一个巨大的文件?还有其他方法可以上传大文件吗?

1 个答案:

答案 0 :(得分:0)

配置struts的最大限制 调节器 controller processorClass =“your class”nocache =“true”locale =“true”contentType =“text / html; charset = UTF-8”** maxFileSize =“15G”/ **

当您使用apache.commons.fileuploa-1.1时,存在一个约束,即FileUpload拒绝解析未知长度的请求。在随后的版本中引入了流来克服大小问题。 以下问题在1.2& amp;中的apache.commons.fileupload中报告。 1.3  1.上传后,不删除临时文件  2.输入流未关闭,导致memleak。

参考:refuses parsing request of unknown lenght Memleak when stream is not closed. Memleak

希望它有所帮助......