Tuesday, May 15, 2007

Process a zip file

Some one on the forum asked for an example of how to bulk upload files. Here is an example I used a couple years ago of processing a zip file and uploading the individual files into a table. Then we made an application to manage the file and followed "Create a Procedure to Download Documents" to download.

Here's the sql for the table and sequence:

create table docs(doc_id number,blob_content blob,file_name varchar2(2000));

create sequence doc_id_seq;

1 comment:

Marcelo Ochoa said...

Hi Kris:
If you are using Oracle 10g+ with Java Enabled the procedure can be fully web enabled.
It means, you can upload the zip file by web using mod_plsql upload functionality, then open the zip input stream with a Java Stored Procedure and finally move to the target tables.
We use this functionality at DBPrism CMS backup/restore operations.
The code can be found at Source Forge CVS, opening the zip stream, public static int importDir(Connection conn, InputStream is, String dir).
The code which receives the mod_plsql multi-part form data, processUpload, with his CallSpec.
Best regards, Marcelo.

Disqus for Kris' Blog