Type Function
Library zip.*
Return value none
Revision 2018.3333
Keywords zip, compress
See also zip.uncompress()


Creates or adds files to a zip archive.


zip.compress( options )
options (required)

Table. A table of options for the function call — see the next section for details.

Options Reference

zipFile (required)

String. The zip file to compress files to.

zipBaseDir (required)

Constant. The base directory containing the zip archive.

srcBaseDir (required)

Constant. The base directory containing the files to add to the zip archive.

srcFiles (required)

Array. A table specifying a set of file names to compress into the archive.

password (optional)

String. An optional password for the zip file, using standard Zip 2.0 encryption (WinZip AES encryption is currently not supported).

listener (required)

Listener. The listener function invoked at the end of the operation.


local zip = require( "" ) 

local function zipListener( event )

    if ( event.isError ) then
        print( "Error!" )
        print ( event["type"] )  --> compress
        print ( event.response[1] )  --> space.jpg
        print ( event.response[2] )  --> space1.jpg
        print ( event.response[3] )  --> space2.jpg

-- Attempts to compress files in the "srcFiles" parameter to ""
local zipOptions = { 
    zipFile = "",
    zipBaseDir = system.DocumentsDirectory,
    srcBaseDir = system.ResourceDirectory,
    srcFiles = { "space.jpg", "space1.jpg", "space2.jpg" },
    listener = zipListener
zip.compress( zipOptions )