How to extract a zip file?

Hello,
on the forum we just saw posts how to download a zip file or how to create a zip files from existing files.

We have a zip-file on a remote URL and want to have this workflow:

  1. Download ZIP File. Result is an object with name, type, sizeBytes and base64Data
  2. Unzip that zip file and store all .png in retool storage (could be s3 also)

How to achieve step 2 ?

Currently playing around with JSZip, but do not get any results.
Anyone with an idea how to solve this?

Thanks!

I've found that for working with physical files, the package tmp is quite useful.
You can download the file from the remote source, then save it to a temporary file location using tmp and fs in Node. That'll furnish you with a physical file and path to then feed into any of the common unzip packages. You can then create a temporary directory using tmp, and unzip to that directory.

Once you have the zip file unpacked, you can read all the files in with fs again, and store their bytes where you need - Retool storage, S3, etc. - with resource steps and loops.

You can also explore doing this all with streams, but the hassle doesn't seem worth it to me, when Retool does support temporary files and directories on the underlying servers.

2 Likes