Nimbu Developer Docs
Module Reference

zip

Build in-memory ZIP archives and return as base64.

What This Adds In Cloud Code

  • Assemble multi-file exports without external storage.
  • Works well for generated CSV/PDF bundles.
  • Returns base64 ZIP ready for API response or upload.

Quick Start

const Zip = require('zip');
const archive = Zip.create([{ filename: 'readme.txt', contents: 'SGVsbG8=' }]);

API

FunctionParamsReturnsNotes
create(entries)entries: { filename, contents }[]string | nullcontents must be base64 per entry.

Practical Example

const CSV = require('csv');
const Zip = require('zip');

const csvBase64 = CSV.to_csv([['id'], ['1'], ['2']]);
const zipBase64 = Zip.create([{ filename: 'export.csv', contents: csvBase64 }]);
response.success({ zip: zipBase64 });

Downloading as a File

In a route or extension, combine with res.send() to trigger a browser download:

const CSV = require('csv');
const Zip = require('zip');

const csvBase64 = CSV.to_csv([['id'], ['1'], ['2']]);
const zipBase64 = Zip.create([{ filename: 'export.csv', contents: csvBase64 }]);

res.send(zipBase64, {
  filename: 'export.zip',
  type: 'application/zip'
});

Limits

The archive is built in memory, so its size is capped:

LimitValue
Entries per archive10,000
Decoded content, file names included100 MB by default (can differ per plan)

Going over either limit throws an Error you can catch:

  • zip cannot contain more than 10000 entries
  • zip contents cannot exceed 104857600 bytes (the number is the cap for your plan)
try {
  const zipBase64 = Zip.create(entries);
  res.send(zipBase64, { filename: 'export.zip', type: 'application/zip' });
} catch (error) {
  res.error(422, error.message);
}

Failure Modes & Gotchas

  • Empty input returns null.
  • Each entry contents must already be base64.
  • For exports near the cap, split the data over several archives.

On this page