25.6 ZIP Function

This function compresses a list of files (usually obtained from one of the APEX_EXPORT routines) into a single BLOB containing a .zip archive. All text content in the resultant .zip file is encoded as UTF-8.

All file names within the archive must be unique to prevent the accidental overwriting of files in the application export (an exception raises otherwise).

Additional files (p_extra_files) may also be added to the resultant archive, such as a simple README.txt file or licensing information.

Syntax

APEX_EXPORT.ZIP (
    p_source_files  apex_t_export_files,
    p_extra_files   apex_t_export_files DEFAULT apex_t_export_files() )
    RETURN BLOB;

Parameters

Table 25-6 ZIP Parameters

Parameter Description
p_source_files A table of files. For example, from apex_export.get_application.
p_extra_files Optional additional files to add to the resultant .zip archive.

Returns

This function returns a BLOB containing the compressed application files and any extra files, in ZIP format.

Example

DECLARE
  l_source_files apex_t_export_files;
  l_extra_files apex_t_export_files;
  l_zip blob;
BEGIN
  l_source_files := apex_export.get_application(
    p_application_id => 100,
    p_split => true );

  l_extra_files := apex_t_export_files(
    apex_t_export_file(
      name => 'README.md',
      contents => 'An example exported application.' ),
    apex_t_export_file(
      name => 'LICENSE.txt',
      contents => 'The Universal Permissive License (UPL), Version 1.0' ) );

  l_zip := apex_export.zip(
    p_source_files => l_source_files,
    p_extra_files => l_extra_files );

    sys.dbms_output.put_line(
      'Compressed application export to zip of size; '
      || sys.dbms_lob.getLength( l_zip ) );
END;