Skip to Content
StepsZipper

Zipper Step (Zipper)

A Zipper step collects files (e.g., generated images, JSON outputs) from prior Flow steps and bundles them into a downloadable .zip archive. This is especially useful when you want to give users a convenient “Download All” link at the end of a Flow.

Overview

A typical Zipper step reads from one or more source steps and combines their results:

  1. Image Steps (ImageGenerator)
    • Locates the produced images and appends them into the zip file.
  2. Any Other Step
    • Takes the JSON result from that step and appends it as a .json file.

The final .zip is uploaded and the step results in a URL for easy user download.


Usage Example

{ id: 'zipOutput', type: 'Zipper', parameters: { sources: [ 'ingredientsImageGenerator', 'recipeImageGenerator', 'recipeObjectsGenerator', ], filename: 'all_output.zip', }, }

Explanation

  • id: Unique identifier, here “zipOutput”.
  • type: Must be “Zipper”.
  • parameters.sources: An array of step IDs whose results should be zipped. You can list: steps that produced images (ImageGenerator) or steps that generated JSON (ObjectGenerator, or any other type).
  • filename: (Optional) The desired zip file name, e.g. “all_output.zip”. Defaults to “result.zip” if none is specified.

When this step runs, it:

  1. Iterates over each source step in parameters.sources.
  2. If it’s an ImageGenerator step:
  • Grabs all the images in that step’s results (found in innerResults.[stepId].jobResults).
  • Adds each image to the zip as img_0_0.jpg, img_0_1.jpg, etc.
  1. If it’s any other type (e.g. ObjectGenerator), serializes that step’s final JSON and stores it as [stepId].json
  2. Uploads the resulting .zip to S3, returning a final url in its result.

Final Output

After a Zipper step completes, you’ll find in the Flow’s results something like:

{ "zipStep": { "url": "https://lensless.io/runs/results/zips/123/all_output.zip" } }

Users can then download the combined content.

Parameters

FieldTypeDefaultDescription
sourcesstring[]nullArray of step IDs to collect from. If a listed step is type ImageGenerator, the images are appended. Otherwise, a JSON file is created.
filenamestringnullThe name of the zip file.

Internals & Considerations

  1. Image Steps: The Zipper specifically looks at results.[stepId] to gather results. In the case of ImageGenerator results, it will include all the generated images from that step. For all others, it will include the results in a JSON file.
  2. File Naming: • Images are named img_[sourceIndex]_[imageIndex].jpg, e.g. img_0_3.jpg. • JSON results are named after the step ID, e.g. recipeGenerator.json.
  3. Billing: • The archive size in bytes is used to compute a cost at $0.0035 per MB + $0.01 per invocation. See Pricing for details.

Edge Cases: • If a source step’s images or JSON are not found, that step is skipped. • If no images or JSON are found from any sources, you’ll still get a .zip (potentially empty).

Last updated on