62.4 GET_DIR_ENTRIES Function
This function returns a table of directory entries containing information about each file in the provided ZIP file. The returned table of records is indexed by the file names (including the path).
Syntax
APEX_ZIP.GET_DIR_ENTRIES (
p_zipped_blob IN BLOB,
p_only_files IN BOOLEAN DEFAULT TRUE,
p_encoding IN VARCHAR2 DEFAULT NULL )
RETURN t_dir_entries;
Parameters
Parameter | Description |
---|---|
p_zipped_blob |
The BLOB containing the ZIP file. |
p_only_files |
Only return files, not directories, in the directory listing. |
p_encoding |
The encoding used to compress the file. |
Returns
A table of directory entries.
Example
The following example reads a ZIP file from a table, extracts it, and stores all files of the ZIP file into my_files
.
DECLARE
l_zip_file blob;
l_unzipped_file blob;
l_dir apex_zip.t_dir_entries;
l_file_path varchar2(32767);
BEGIN
SELECT file_content
INTO l_zip_file
FROM my_zip_files
WHERE file_name = 'my_file.zip';
l_dir := apex_zip.get_dir_entries (
p_zipped_blob => l_zip_file );
l_file_path := l_dir.first;
WHILE l_file_path IS NOT NULL LOOP
l_unzipped_file := apex_zip.get_file_content (
p_zipped_blob => l_zip_file,
p_dir_entry => l_dir(l_file_path) );
INSERT INTO my_files ( file_name, file_content )
values ( l_file_path, l_unzipped_file );
l_file_path := l_dir.next(l_file_path);
END LOOP;
END;
Parent topic: APEX_ZIP