Docly Developers
Function API only Updated 17 Oct 2026

createZip(content)

Creates a ZIP-file and adds specified files and folders to it.

Parameters

contentobjectrequired

An object where each key is a path inside the ZIP and each value is the file content as a byte array (byte[]). A key ending in / creates an empty folder (use null as the value). A file key with a null value is skipped without an error. Folders in a path are created automatically.

Returns

The ZIP file as a byte[]. The ZIP is built in memory on every call and is never cached. Throws if the object is empty or a value is not a byte array.

Example

Normal JavaScript, running in the browser or on the Docly™ server.
let somedata = docly.textEncode("testing testing", "utf8"); // Create a byte array from text
let content = {
    "Test file 1.txt" : somedata, // Always specify byte arrays
    "Folder/Another file.txt" : somedata,
    "Folder 2/" : null // Create an empty folder
};
let zip = docly.createZip(content);
return zip;