views:

106

answers:

2

If I accept a file from a MultipartRequest and call

File f = request.getFile("fileName");

Is the file written to disk (as a temp file) or is it only stored in memory at this point?

A: 

This is implementation dependent. You have no need to know, short of wanting to short-circuit an operation like "move." But even the File object returned could be an implementation-dependent interface that supports move semantics from memory to disk.

Chris Kaminski
+2  A: 

Assuming you're talking about the o'Reilly MultipartRequest it'll always be written to disk according to the link.


Update If you're talking about the Spring commons FileUpload component, it does support this setup. One of the properties you can set is setMaxInMemorySize(int bytes) which determines the max size of a file that will be held in memory and not written to disk.

Brabster
Thanks, reading the documentation on the link you provided for o'Reilly clearly states that getFile(String s) "Returns a File object for the specified file saved on the server's filesystem, or null if the file was not included in the upload."
Flash84x
You're right, despite providing the link I misread the constructor docs! Updated.
Brabster