Ivan Vasquez schrieb:

Hi,

What's the preferred way to upload files into a database in a J2EE Web
application?


Is there any way to stream the file straight from the HttpServletRequest
to the database without staging it in the server's filesystem?


Thank you,
Ivan.



That's how I use it. But in my case I want to store a file on the server. But it should be easily possible to put the Stream to CLOB or something like this.

streamIn = file.getInputStream();
streamOut = new FileOutputStream(fileName);

int bytesRead = 0;
byte[] buffer = new byte[8192];

while ((bytesRead = streamIn.read(buffer, 0, 8192)) != -1) {
     streamOut.write(buffer, 0, bytesRead);
}

streamOut.close();
streamIn.close();
file.destroy();

file is a FormFile object which you can use with Struts with the <html:file > tag.

Cheers,
Axel

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to