问题
Using a file upload in my project as :
<s:form id="uploadData" action="UploadAction" namespace="xyz" validateFields="false" method="post" enctype="multipart/form-data">
But the request.getContentLength() method returns correct value for less than 2 gb and 0 for anything above it.
The probable reason being datatype of the content-length as int. Is there any other way where the request parameter: content-length can be converted into long type in order to support uploads greater than 2gb.
please guide us how to convert the content length request header to long to support file upload greater than 2gb
回答1:
It's because the getContentLength() method in the Servlet API is defined as int
. Actually, it should return -1
for files (requests) bigger than 2gb.
If you're using Servlet API 3.1 (e.g. Tomcat 8), you can use getContentLengthLong() method.
来源:https://stackoverflow.com/questions/34741419/request-getcontentlength-return-0-when-file-size-is-greater-than-2gb