0
votes

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
Are you using x32 or x64 ? - joaumg
Have you tried to get it from the header? - Aleksandr M
@joaumg we are using x64 - Sahil Garg
Set? You were talking about getting it, not setting. See stackoverflow.com/q/11466905/1700321. - Aleksandr M
How do you think uploading a file depends on a content length? - Aleksandr M

1 Answers

1
votes

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.