What do you want to accomplish exactly?
Do you want to store the file in DB? Do you want to serve the file to the user?
What I want to accomplish is:
Users remote to the application server can upload a file from their local machine to the machine where the app server is. There are other processes running on the machine, which will further process the uploaded files once they are placed in a well known dir with a particular file name pattern.
At the moment I can do this, it works fine (unless the file is so big it blows the heap), but I could not help but notice that the file is getting uploaded to /tmp as part of the fileUpload processing, and was wondering is there a way I can use this feature (the temp-file creation) to avoid reading the contents of the file (which I do not care about) into memory?
Let me see if I understand you (because you basically just wrote what you originally said in your question).
You want to read a file, but not read it in memory first? Like reading XML by using SAX which reads it line by line and not DOM which loads the entire file in memory?
If this is what you want to accomplish, then it depends on what kind of InputStream you are using, and how you are reading the file (ie byte for byte). (But something tells me you didn't ask for this)
I dont really want to read the file, but as far as I can see, I have to read it using the fileUpload control. At the moment, from my original post, you can see that my backing bean has a getter and setter with byte for the file contents. This type of backing bean method was the only example I could find. Like your analogy to a DOM versus SAX parser, I am currently using the DOM method, as the whole file is being passed as a byte array. I would like to have the equivalent of SAX.
Is there another way?
I think this is possible using temp file and InputStream. The data attribute accepts value expression pointing to a reference of type InputStream. This is from the seam docs:
data — this value binding receives the binary file data. The receiving field should be declared as a byte or InputStream (required).
So if you read the input stream and store it somewhere else without capturing the whole data in the memory.
I will play around with that method and see what the results are. I could not find any InputStream examples out there when I started.
To Follow up, the InputStream method worked fine.