2013/11/23 Yang,Gem <ya...@oclc.org>: > Hi there, > > Here is the context for this question: I have a file upload service running > on Tomcat 6/7 using PUT method. The file could be very big, say a few GBs. > The service needs to save the file to disk first. Then do checksum, digest > the content(running some format conversion code against it), then store the > file into a storage system, delete the temporary file on disk at last. > > I have a few questions about how Tomcat serves PUT request: > > 1. What is the max file size that is allowed for a PUT request? I have > seen some information for POST request, but can not find "official" answer > with regard to PUT.
There is no limit neither for PUT nor for POST, if you consume the InputStream by yourself. There is a 2Mb limit for POST but only if you are calling one of request.getParameter() methods and Tomcat has to consume and parse the request into parameters. This parsing happens only when HTTP request has Content-Type of "application/x-www-form-urlencoded". Servlet 3.0+ applications are also able to consume requests that have Content-Type of "multipart/form-data", but access to this feature is allowed only if you have explicit configuration for that in your web application. Such configuration included limits on the size of uploaded file. See Servlet specification for details. There also exist 3rd party libraries that deal with "multipart/form-data" requests. An example is Apache Commons Fileupload. > 2. Suppose the file is allowed for upload. Tomcat must have saved it to > disk somewhere before hand it out to the service. How can I get access to > this file? I do not want to copy it via Servelet.getInputStream as it > doubles the temp storage size. Request.getInputStream() reads from the network. It is your own job to consume that as soon as the bytes arrive. > 3. Where are the related source code that could answer the first 2 > questions. Can someone please give me some pointers? http://tomcat.apache.org/svn.html http://tomcat.apache.org/download-70.cgi#Source_Code_Distributions You may use the Manager web application as an example (webapps/manager, java/org/apache/catalina/manager). Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org