无法用struts 2.0 frmework上传2gb大小的文件 [英] Not able to upload 2gb size file with struts 2.0 frmework

查看:266
本文介绍了无法用struts 2.0 frmework上传2gb大小的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,所有最新的浏览器,支持2 GB的文件上传过程的大小限制,
现在我们正在使用以下在我们的应用
Java,JSP,Struts 2.0框架,我们无法上传2gb大小的文件,所以我有网络搜索,我可以找到 struts.multipart.maxSize 属性配置 struts.xml ,我已经将这个值设置为2gb大小,我还在tomcat server.xml中设置了 maxPostSize size属性文件增加postdata大小与请求。



仍然我们无法从浏览器上传2GB大小的文件。



请给我们一些建议,在Apache服务器,tomcat,struts或浏览器中有没有可用的设置,然后让我们知道这些。



我们没有使用fileUpload拦截器在我们的文件上传操作中

 < action name =fileUploadmethod =fileUploadclass =fileUploadAction> ; 
< interceptor-ref name =check>
< / interceptor-ref>
< result name =Errorjsp> tFrame.jsp< / result>
< result name =insert> FileFrame.jsp< / result>
< / action>

和我们的java方面的动作有上传的扁平逻辑,在服务器端代码没有文件大小限制验证。

我想知道为什么大文件没有上传的原因?

为了更新更新,我们找到了在我们的环境中创造的问题是CDN网络。客户端请求通过浏览器将文件发送到cdn网络,然后cdn网络将这些文件发送到实际的服务器。

当我们要求超过cdn网络时,才会发生问题2 GB的大小的文件,所以它是不相关的浏览器问题。

问题没有发生与cdn网络,当我们发送文件字节块到cdn网络,意味着什么时候我们使用一个java演示程序发送文件字节的块请求。所以从这个分析,我们可以说cdn网络正常工作,当我们发送数据在块编辑。



,在我们的情况下,我们发送文件上传请求throgh浏览器,所以我们不能发送块请求,所以现在我的问题是,任何技术或机制可用来解决我们的问题是否有任何js或请求机制可用,通过浏览器发送块字节请求?有没有其他方法可以解决我们的问题?



感谢和问候Yatin Baraiya

解决方案

Struts2允许你将文件上传到2GB,这就是允许的最大尺寸


此设置默认为大约2兆字节,应该是调整到最大文件大小(最多2个),您将需要框架接收。

要做到这一点,您需要设置两个:
$ b


  1. 设置常用的<常数名称=struts.multipart.maxSize值=2147483648/> ,用于整体请求大小; 设置FileUpload拦截器参数,对于单个文件的最大尺寸,在本地对一个操作或者对一个包来说是通用的:

     < interceptor-ref name =fileUpload> 
    < param name =maximumSize> 2147483648< / param>
    < / interceptor-ref>


配置:目前,您可以发送2千兆字节的内容,但最大文件大小为2兆字节,例如。 1000个文件,每个文件最大为2mb。



将上面的设置应用到你的配置中,例如:

< pre class =lang-xml prettyprint-override> < action name =doUploadclass =com.example.UploadAction>
< interceptor-ref name =defaultStack>
< param name =fileUpload.maximumSize> 2147483648< / param>
< /拦截器>
< result name =success> good_result.jsp< / result>
< / action>


Now days all latest browser, support 2 gb size limit for file upload process, Right now we are using following in our application Java, JSP, Struts 2.0 framework , we did not able to upload 2gb size file, so i have search in net, i am able to find struts.multipart.maxSize property configuration in struts.xml, i have set this value up to 2gb size, i have also set maxPostSize size property in tomcat server.xml file for increase postdata size with request.

Still we did not able to upload 2gb size file from browser.

Please some one advice us, is there any setting available in Apache server, tomcat, struts or browser, then let us know about those.

We are not using fileUpload interceptor in our file upload action

<action name="fileUpload" method="fileUpload" class="fileUploadAction">
<interceptor-ref name="check">
</interceptor-ref>
<result name="Errorjsp">tFrame.jsp</result>
<result name="insert">FileFrame.jsp</result>
</action>

and our java side action have flat logic of upload , there is no filesize limit validation at server side code.

i want to know the reasons why large file did not upload?

for more update , we found that issue creating in our environment is CDN network. Client request through browser to send file to cdn network , and then cdn network send those file to actual server.

Issue only happen due to cdn network when we request of more than 2 gb size file,so it is not related to browser issue.

Issue not happen with cdn network , when we send out file byte to chunk to cdn network,means when we send chunk request of file byte using one java demo program. so from this analysis, we can say that cdn network work properly when we send data in chunk-ed.

and in our case we sending file upload request throgh browser, so we can't send chunk-ed request, So now my question is that is any technique or mechanism available to resolve our issue Is there any js or request mechanism available , which send chunk byte request through browser? Is there any other technique available to resolve our issue?

Thanks and regards Yatin Baraiya

解决方案

Struts2 lets you upload file UP TO 2GB, that is the maximum allowed size for a Request:

This setting defaults to approximately 2 megabytes and should be adjusted to the maximum size file (2 gigs max) that your will need the framework to receive.

To do that, you need to set both:

  1. set the common <constant name="struts.multipart.maxSize" value="2147483648" />, for the overall request size;

  2. set the FileUpload Interceptor parameter, both locally to an Action, or common to a package, for the single file maximum size:

    <interceptor-ref name="fileUpload">
        <param name="maximumSize">2147483648</param>
    </interceptor-ref>
    

The .2 is the missing piece in your configuration: currently, you are allowed to send 2 GigaBytes of stuff, but with a maximum filesize of 2 MegaBytes, eg. 1000 files of 2mb max each one.

Apply the above setting to your configuration to make it work, eg:

<action name="doUpload" class="com.example.UploadAction">
    <interceptor-ref name="defaultStack">
        <param name="fileUpload.maximumSize">2147483648</param>
    </interceptor>
    <result name="success">good_result.jsp</result>
</action>

这篇关于无法用struts 2.0 frmework上传2gb大小的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆