You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by hu...@iol.pt on 2004/06/25 13:20:46 UTC
HSQL upload and download
Hi, users of cocoon.
My name is Hugo Marcelino and i came across with the following problem. I'm developing a web application that can perform a documental managment. How i'm doing this ? I thougth use hsqldb that comes with the cocoon, and at the begining everthing was going ok. But now i have the following problem. I need to upload the content of a file, that can be any kind of file, into the database. The field in the database is binary and i discover that binary files only suport hexadecimal caracters and then i need to perform a download ( using http ) file from the database into the localdisk.
Now, how do i trigger a download from the database into the localdisk ?
And does anyone have any algorithm on how to transform the content of the file using xsp to insert into the database ?
Because i believe that something is wrong with mine. (i read the content of the file and transform into hexadecimal caracters)
/* fiile reading and hexadecimal transformation*/
String pathfile = "d:\\tempfile.doc";
FileInputStream upload = new FileInputStream (pathfile);
int len = upload.available();
byte contentFile[] = new byte[len];
upload.read(contentFile);
StringBuffer hexFile = new StringBuffer();
for (int i = 0; i < contentFile.length; i++) {
temp = (int)contentFile[i];
hexFile.append(Integer.toHexString(temp));
}*/
upload.close();
String filename = pathfile.substring(pathfile.lastIndexOf(File.separatorChar)+1,pathfile.length());
thank you in advance .
Hugo Marcelino
25-06-2004
___________________________________________________________________________________________
IOL - Portal Oficial do 10º Festival Super Bock Super Rock.
Ouve a Rádio do Festival no Cotonete!
http://www.cotonete.iol.pt/quiosque/destaques/sbsr04
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: HSQL upload and download
Posted by Tuomo L <tl...@cc.hut.fi>.
Hugo,
There's no need to use XSP script for this. Cocoon has a built-in upload
mechanism, that can be enabled from web.xml. For saving the uploads in a
db, you can use the modular DatabaseAddAction.
See: //wiki.apache.org/cocoon/ModularDatabaseActions
and http://wiki.apache.org/cocoon/ModularDatabaseActions
For download, there's a reader that reads binary from db and serializes it
for saving the file on local disk.
See: http://cocoon.apache.org/2.1/userdocs/readers/database-reader.html
Hope this helps! :)
-Tuomo
On Fri, 25 Jun 2004 hugomarcelino@iol.pt wrote:
>
> Hi, users of cocoon.
>
> My name is Hugo Marcelino and i came across with the following problem. I'm developing a web application that can perform a documental managment. How i'm doing this ? I thougth use hsqldb that comes with the cocoon, and at the begining everthing was going ok. But now i have the following problem. I need to upload the content of a file, that can be any kind of file, into the database. The field in the database is binary and i discover that binary files only suport hexadecimal caracters and then i need to perform a download ( using http ) file from the database into the localdisk.
>
> Now, how do i trigger a download from the database into the localdisk ?
>
> And does anyone have any algorithm on how to transform the content of the file using xsp to insert into the database ?
>
> Because i believe that something is wrong with mine. (i read the content of the file and transform into hexadecimal caracters)
>
> /* fiile reading and hexadecimal transformation*/
> String pathfile = "d:\\tempfile.doc";
> FileInputStream upload = new FileInputStream (pathfile);
> int len = upload.available();
> byte contentFile[] = new byte[len];
> upload.read(contentFile);
> StringBuffer hexFile = new StringBuffer();
> for (int i = 0; i < contentFile.length; i++) {
> temp = (int)contentFile[i];
> hexFile.append(Integer.toHexString(temp));
> }*/
> upload.close();
> String filename = pathfile.substring(pathfile.lastIndexOf(File.separatorChar)+1,pathfile.length());
>
> thank you in advance .
> Hugo Marcelino
> 25-06-2004
>
> ___________________________________________________________________________________________
>
> IOL - Portal Oficial do 10º Festival Super Bock Super Rock.
> Ouve a Rádio do Festival no Cotonete!
> http://www.cotonete.iol.pt/quiosque/destaques/sbsr04
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org