Compress files

Compress files is one of the actions under Files by Workato application. It allows you to compress multiple files into one .zip file. The source files can come from any app (e.g. Amazon S3, Dropbox, Salesforce, etc.)

Example: Compress all files in a folder

In this section, we will go through one example of how to compress all files in a folder.

We will use an SFTP folder for this example. However you can use this same method with any other app like Amazon S3, Box, Dropbox, Salesforce, etc.

The recipe may look a bit daunting at first, but once you get the idea it is actually quite straightforward. Let's go through the thought process step by step:
1) We have a folder in SFTP with several files. We need to compress all files in that folder into one .zip file.

2) Examining the Compress files action, we see that it needs a list of File name and File contents:

3) To get File name and File contents of every file in the folder, follow these steps:

List all items in the folder (including both files & sub-folders):

Now we will go through each item one by one. To do this, we use a "For each" step (a.k.a. Repeat Step):

First we need to make sure this item is a file and not a folder:

If it's a file, then get the File contents:

Now we will save File name and File contents into a list. The first file in the folder (index = 0) will be saved into list-0:

Repeat this step for the rest of the files. In this example, there are 3 files in total. We save them into 3 lists: list-0, list-1, list-2:

4) Now we are ready to use Compress files action.
From the App data box, drag & drop File name and File contents pills from the 3 lists into Compress files action: