Reputation: 6749
If I use the annotation (@MultipartConfig(maxFileSize=XXX)
) that works, but the web.xml
variety (<max-file-size>XXX</max-file-size>
) only seems to work when <file-size-threshold>
is also present.
This seems wrong, am I right?
EDIT: When it does work (because I've added the file-size-threshold
tag) and I upload a larger-than-the-limit file, I get a different exception than when I use the annotation. Definitely seems odd to me.
EDIT2: Just to add more detail, I get a SizeLimitExceededException
when I set a max file size via the annotation, and get a FileSizeLimitExceededException
when I set a max file size (with a 0 file size threshold to make it work at all). Both exceptions print the limit I set in the max file size in the exception message.
Upvotes: 1
Views: 1264
Reputation: 22461
Actually the API Documentation for MultipartConfig specifies a default value of 0
.
public abstract int fileSizeThreshold
The size threshold after which the file will be written to disk
Default:
0
Unfortunatelly the multipart-configType
(in web-common_3_0.xsd
) does not specify a default value:
<xsd:element name="file-size-threshold"
type="xsd:integer"
minOccurs="0"
maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
The size threshold after which an uploaded file will be
written to disk
</xsd:documentation>
</xsd:annotation>
</xsd:element>
I also couldn't find anything about it in JSR 315. While we could reason that minOccurs="0"
implies that file-size-threshold
is optional, there is nothing in the specs describing the intended behavior when this element is absent; so it is up to the vendor.
Hint: Try <file-size-threshold>0<file-size-threshold>
Hint 2: If it doesn't work open an issue for for the vendor (try the app Server issue tracker or the official issue tracker for whichever javax.servlet
implementation you / they use). Do not use the word "wrong", instead go with terms such as "sensible defaults" and "metadata interoperability" (it will dramatically improve your chances):D.
Upvotes: 1