This package manages the zipping and unzipping of files.
This procedure adds a single file to a zip file.
Note:
After all files are added, you must callAPEX_ZIP.FINISH
.APEX_ZIP.ADD_FILE ( p_zipped_blob IN OUT NOCOPY BLOB, p_file_name IN VARCHAR2, p_content IN BLOB );
Table 27-1 ADD_FILE Procedure Parameters
Parameter | Description |
---|---|
|
BLOB containing the zip file. |
|
File name, including path, of the file to be added to the zip file. |
|
BLOB containing the file. |
This example reads multiple files from a table and puts them into a single zip file.
declare l_zip_file blob; begin for l_file in ( select file_name, file_content from my_files ) loop apex_zip.add_file ( p_zipped_blob => l_zip_file, p_file_name => l_file.file_name, p_content => l_file.file_content ); end loop; apex_zip.finish ( p_zipped_blob => l_zip_file ); end;
This procedure completes the creation of a zip file after adding files with APEX_ZIP.ADD_FILE
.
APEX_ZIP.FINISH ( p_zipped_blob IN OUT NOCOPY BLOB );
Table 27-2 FINISH Procedure Parameters
Parameter | Description |
---|---|
|
BLOB containing the zip file. |
See "ADD_FILE Procedure" for an example.
This function returns the BLOB of a file contained in a provided zip file.
APEX_ZIP.GET_FILE_CONTENT ( p_zipped_blob IN BLOB, p_file_name IN VARCHAR2, p_encoding IN VARCHAR2 DEFAULT NULL ) RETURN BLOB;
Table 27-3 GET_FILE_CONTENT Function Parameters
Parameter | Description |
---|---|
|
This is the BLOB containing the zip file. |
|
File name, including path, of a file located in the zip file. |
|
Encoding used to zip the file. |
See "GET_FILES Function" for an example.
This function returns an array of file names, including the path, of a provided zip file that contains a BLOB.
APEX_ZIP.GET_FILES ( p_zipped_blob IN BLOB, p_only_files IN BOOLEAN DEFAULT TRUE, p_encoding IN VARCHAR2 DEFAULT NULL ) RETURN t_files;
Table 27-5 GET_FILES Function Parameters
Parameter | Description |
---|---|
|
This is the zip file containing the BLOB. |
|
If set to |
|
This is the encoding used to zip the file. |
Table 27-6 GET_FILES Function Returns
Return | Description |
---|---|
t_files |
A table of file names and path. See "Data Types" for more details. |
This example demonstrates reading a zip file from a table, extracting it and storing all files of the zip file into my_files
.
declare l_zip_file blob; l_unzipped_file blob; l_files apex_zip.t_files; begin select file_content into l_zip_file from my_zip_files where file_name = 'my_file.zip'; l_files := apex_zip.get_files ( p_zipped_blob => l_zip_file ); for i in 1 .. l_files.count loop l_unzipped_file := apex_zip.get_file_content ( p_zipped_blob => l_zip_file, p_file_name => l_files(i) ); insert into my_files ( file_name, file_content ) values ( l_files(i), l_unzipped_file ); end loop; end;