Java – limit upload size in embedded jetty

I'm trying to limit the maximum upload file size that jetty can accept I have read several reports, and the following should be valid

contextHandler. setMaxFormContentSize(XXX);

I noticed that this does work on our login form. If I set it too low, the submission will be rejected However, for a reasonable value (such as 5000), it will not fail large uploads (such as 9mb), possibly because uploads are set to multipart

I can continue to implement our own upload servlet, but I will insist on using jetty Any ideas on how to successfully limit the upload size? I will provide the answer in the code instead of the configuration file. We may need to change it according to the remote user settings at startup

thank you.

Solution

You might consider using Apache Commons fileUpload instead of what comes with jetty You will get a very rich set of configuration options

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>