views:

51

answers:

2

Posting this one for a friend. They have an Icefaces app that uses Icefaces's inputfile functionality but it attempts to upload the file to a temporary directory before it allows access to it. Long story short, there is no access to the temp location so copying the file (which will enventually end up in a database) is not possible. Is it possible to use a Java Servlet instead to upload the file and stream the contents to where they do have access without first having the file saved to a temporary location?

+2  A: 

Yes, that's absolutely possible. The servlet's doPost() method can do whatever it wants with the input, and is designed for processing it in a streaming manner. However, wiht a bare servlet you'd have to parse the request body manually. Fortunately, Apache Commons FileUpload can do that for you.

Michael Borgwardt
Thank You, I will give that a shot. I've heard good things about Commons FileUpload as well.
Vinny
A: 

Since it was tagged with iceFaces, I am assuming that's what your friend is using in developing this. If that's the case you can use the inputFile component.

Here is a tutorial on how to do it. You can also specify absolute path. It basically uses Commons File Upload under the hood.

CoolBeans