I am trying to upload very big files greater than 1gb. I am using MultipartConfig and HttpServletRequest.getPart(String) from servlet api. I deployed in my server and tried uploading a file and its working like a charm.
Then I went on reading about MultipartConfig in http://docs.oracle.com/javaee/6/tutorial/doc/gmhal.html. I understood that when large files are uploaded it writes parts of the file to a temporary location when the threshold is reached. And later on we have to delete the temporary files using part.delete().
What if I don't want to mention the temporary location? Will something bad happen to my application while uploading big files? I don't want to mention a temporary location becasue we cant gurantee about the production environment.
Hi Jaikiran, I did a search in my server root folder and got this location for the temporary files C:\opt\jboss\jboss-eap-6.1\standalone\tmp\work\jboss.web\default-host\file-upload. Thanks for the help.
chaitanya karthikk wrote:
Is javax.servlet.context.tempdir context attribute set in every application server by default?
Yes, that's mandated by the Servlet spec:
Servlet 3.0 spec wrote:
4.8.1 Temporary Working Directories
A temporary storage directory is required for each servlet context. Servlet containers
must provide a private temporary directory for each servlet context, and make it
available via the javax.servlet.context.tempdir context attribute. The objects
associated with the attribute must be of type java.io.File.
The requirement recognizes a common convenience provided in many servlet engine
implementations. The container is not required to maintain the contents of the
temporary directory when the servlet container restarts, but is required to ensure
that the contents of the temporary directory of one servlet context is not visible to
the servlet contexts of other Web applications running on the servlet container.
What if I don't want to mention the temporary location?
It will default to the value that's set for the javax.servlet.context.tempdir context attribute, which is set by the server.
Which, in turn, is set by the JVM and can be overridding the "java.io.tmpdir" JVM system property. Been there, did that. This is for Tomcat, mind you, but expect most JEE servers to do likewise.
So your temporary file directory isn't set at the application level. Or strictly speaking, even at the server level. It's at the JVM level and can be set by the production operations staff to wherever is most suitable.
That's assuming that the standard java.io tempfile facilility is being used to allocate and create the tempfiles. Which most of the stock upload handlers will be using.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.