I can't seem to figure out how to properly use FileUploadInterceptor
in Struts2. I have everything wired and it does work. I can specify the file extensions and max file size and it indeed works. The problem is as follows:
- I specify the max file size as 100mb
- When user uploads 110mb the file I can see that
JakartaMultiPartRequest
class handles the file upload with the help commonfile-upload
libraries. This happens BEFORE the file upload interceptor. - Once the user waited for minutes and the file upload is done the file upload interceptor fires and tells the user that the file is too big.
There is something wrong with sequence of events. I would like to looks at content-length header and right away tell the user that the file is too big (before uploading). I understand the header is not always there but if it is there I would like to use it.
Other than overwriting JakartaMultiPartRequest
class I don't understand how to do this.
Edit: Here is the sequence as I understand it:
- User sends multi-part request to server with file upload.
- JakartaMultiPartRequest in Struts2 parses the request and uploads it to Struts2 temp folder.
- The flow finally reaches the file-upload interceptor where max file size and file extension is checked.
From above it is obvious that the upload happened at step#2. The entire file is now on server and only after that file-upload interceptor detects that it is too big.