Below is the code snippet that deals with my uploading .... (using the
MultipartParser)
What can I change in this code so that I don't have to create the file on the
server to get the FileInputStream?
/*
** it's a file part
*/
FilePart filePart = (FilePart) part;
fileName = filePart.getFileName();
log("Filename " + fileName);
if (fileName != null) {
long size = filePart.writeTo(dir);
log("File size " + size);
/*
** create a new file object from the file on the server
** because it seems we cannot write directly to the database
*/
_file = new File(dir + "\\" + fileName);
/*
** Define the table name to be used for the upload
*/
String tableName = "image_upload";
/*
** call stored procedure to get next id
*/
CallableStatement cs = myConn.prepareCall("{ ? = call up_get_next_id(?)}");
cs.setString(2,tableName);
cs.registerOutParameter(1,java.sql.Types.INTEGER);
cs.executeUpdate();
nextId = cs.getInt(1);
log("next key = " + nextId);
/*
** insert the file into the table in binary form
*/
String s = "insert into " + tableName + " (imageid,imagedata," +
formname.get(4) + "," + formname.get(5) + "," + formname.get(2) + "," +
formname.get(7) + ") values (" + nextId + ",?,?,?,?,?)";
PreparedStatement ps = myConn.prepareStatement(s);
FileInputStream fis = new FileInputStream(_file);
ps.setBinaryStream(1,fis, (int)_file.length());
ps.setString(2,(String)formval.get(4));
ps.setString(3,(String)formval.get(5));
ps.setString(4,(String)formval.get(2));
ps.setString(5,(String)formval.get(7));
int rows = ps.executeUpdate();
ps.close();
fis.close();
/*
** delete the file of the server once it has been written to the database
*/
try {
boolean res = _file.delete();
log("file deleted ? " + res);
}
catch (SecurityException se) {
log("delete exception " + se);
}
}
thanks
Parag
Diese Nachricht ist vertraulich. Sie ist ausschliesslich fuer
den im Adressfeld ausgewiesenen Adressaten bestimmt.
Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir um eine kurze Nachricht. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Da wir nicht die
Echtheit oder Vollstaendigkeit der in dieser Nachricht
enthaltenen Informationen garantieren koennen, schliessen wir
die rechtliche Verbindlichkeit der vorstehenden Erklaerungen
und Aeusserungen aus. Wir verweisen in diesem Zusammenhang
auch auf die fuer die Bank geltenden Regelungen ueber die
Verbindlichkeit von Willenserklaerungen mit verpflichtendem
Inhalt, die in den bankueblichen Unterschriftenverzeichnissen
bekannt gemacht werden.
This message is confidential and may be privileged. It is
intended solely for the named addressee. If you are not the
intended recipient please inform us. Any unauthorised
dissemination, distribution or copying hereof is prohibited.
As we cannot guarantee the genuineness or completeness of
the information contained in this message, the statements
set forth above are not legally binding. In connection
therewith, we also refer to the governing regulations of
WestLB concerning signatory authority published in the
standard bank signature lists with regard to the legally
binding effect of statements made with the intent to
obligate WestLB.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html