Hi All, This is regarding the reading of multi part content in java server side.
ServletRequest has an API getParts() API for reading the parts of a multi part request https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getParts() . It has part.getInputStream which can be used to read the content of a specific part. Tomcat also provides an implementation for this API. But this API parses the multi part content and keeps it in memory. If the size increase then the content can be offloaded to disk. Why does the getPart API or any multi part parsing need to load the content in memory ? Why can't direct streaming of content happen ? Loading the content in memory and reading/writing to disk brings extra cost. This will be specially costly when large files are getting uploaded. Is there no way where at least the file content loading could be avoided ? It may be not be a very specific question for tomcat but more applicable to any servlet container. Best Regards, Saurav