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.)

Compress files

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.

You can find the sample recipe here.

Compress files in SFTP directory

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:

Compress files list input

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):

List items in SFTP folder

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

"For each" step

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

Check if item not a folder

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

Get 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:

Add file to a list list-0 contents

  • 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:

Add 3 files into 3 lists

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:

Compress files step Compress files list mapping

5) The last step is uploading the zip file to the destination

Upload file

6) Putting everything together, we have the complete recipe:

Compress files in SFTP directory

results matching ""

    No results matching ""