You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Yozons on Gmail <yo...@gmail.com> on 2020/05/29 21:17:46 UTC

[fileupload] - Replacing with HttpServletRequest.getParts() dynamically

With FileUpload, our JSP pages (HTML documents) can be either 
'application/x-www-form-urlencoded' or 'multipart/form-data' based on 
whether the document includes files to be uploaded or not.

We don't currently assume all requests will include file uploads, and 
with FileUpload, we are able to test the request to see if it's 
multipart, and if so, do special coding using FileUpload.  It works 
great, allow us to process either type of request.

However, when we looked to switch to the HttpServletRequest.getParts(), 
it seems that the file upload logic is tied to a Servlet, requiring that 
we annotate it at compile time with @MultipartConfig.  But since our 
servlet is a common controller and not all requests will be multipart, 
we're stuck as to how to accomplish both regular requests and file 
upload requests.

Also, we have file uploads that may have different 'maxFileSize' 
settings (and even 'location', which we don't know in advance since they 
are turned by customer deployments) values tuned to the types of files 
we're uploading.  But to tune these, we seem to require a servlet for 
each combination and somehow need to know the location at compile time.

Is there a way to switch from FileUpload to the servlet standard 
(getParts) so that we can accept any request from our servlet, and if we 
determine it's multipart, then process it for file uploads, setting max 
file sizes, etc. on a dynamic basis?

Thanks for any ideas...


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org