Type Function Library zip.* Return value none Revision Release 2022.3683 Keywords zip, compress See also zip.uncompress()
Creates or adds files to a zip archive.
zip.compress( options )
Table. A table of options for the function call — see the next section for details.
String. The zip file to compress files to.
Constant. The base directory containing the zip archive.
Constant. The base directory containing the files to add to the zip archive.
Array. A table specifying a set of file names to compress into the archive.
String. An optional password for the zip file, using standard Zip 2.0 encryption (WinZip AES encryption is currently not supported).
Listener. The listener function invoked at the end of the operation.
local zip = require( "plugin.zip" ) local function zipListener( event ) if ( event.isError ) then print( "Error!" ) else print ( event["type"] ) --> compress print ( event.response[1] ) --> space.jpg print ( event.response[2] ) --> space1.jpg print ( event.response[3] ) --> space2.jpg end end -- Attempts to compress files in the "srcFiles" parameter to "test.zip" local zipOptions = { zipFile = "test.zip", zipBaseDir = system.DocumentsDirectory, srcBaseDir = system.ResourceDirectory, srcFiles = { "space.jpg", "space1.jpg", "space2.jpg" }, listener = zipListener } zip.compress( zipOptions )