Apache Tomcat allows for the following configuration, In hard-coded or Annotation format. I'm not sure if the max-file-size is calculated during the upload process or after the file is uploaded to a temp place. The documentation indicates the followings :
The @MultipartConfig annotation supports the following optional
attributes:
location: An absolute path to a directory on the file system. The
location attribute does not support a path relative to the application
context. This location is used to store files temporarily while the
parts are processed or when the size of the file exceeds the specified
fileSizeThreshold setting. The default location is "".
fileSizeThreshold: The file size in bytes after which the file will be
temporarily stored on disk. The default size is 0 bytes.
MaxFileSize: The maximum size allowed for uploaded files, in bytes. If
the size of any uploaded file is greater than this size, the web
container will throw an exception (IllegalStateException). The default
size is unlimited.
maxRequestSize: The maximum size allowed for a multipart/form-data
request, in bytes. The web container will throw an exception if the
overall size of all uploaded files exceeds this threshold. The default
size is unlimited.
annotation approach :
@MultipartConfig(location="/tmp", fileSizeThreshold=1024*1024,
maxFileSize=1024*1024*5, maxRequestSize=1024*1024*5*5)
and here is the hard-coded value:
<multipart-config>
<!– 50MB max –>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
I appreciate it if anyone can clarify if the MaxFileSize is calculated during the upload process.