Download Multiple Files in a Zip from Google Drive

INTRO

I have previously championed the filebyfile method for fetching multiple files from google drive, but I have recently got to thinking about reducing the number of calls required to make this happen. 

This solution will require only 3 calls to google, regardless of the number of files that need to be downloaded to your app. You could reduce this number to 2, depending on what you are doing and how you get / provide the file ID for each file required.

In this example, I fetch a csv list from a spreadsheet, extract the file IDs to a list, send this list to a web app which creates a zip file with all the files in it, then download the zip and extract all the files to a location on the ASD (using Taifun's effective Zip extension)

SETUP

2.  Now we need to collect some data about these files. I am only interested in the png files. With a google spreadsheet I create a function to collect the data about just these files.  Note that the folder ID, where the images are, is hard coded for this example.

3. The above function populates the spreadsheet with this data

4. Now, in the app, on the button press, we call down this data as a csv

5. Once we have the data, we extract just the fileIds and add these to a list. We then send this list of FileIds to a google apps script web app. Note once again, that the folder ID is hard coded in the script, for this example.

6. The web app iterates over the list of fileIds and makes a "blob" from each file, and generates the filename for each blob. Each blob is added to an array of blobs. The blobs are then inserted to a zip file, which is saved to the same folder as the images. Finally, the file ID of the new zip file is returned to the app.

7. When the app receives the zip file ID, it downloads the zip file to the app. Taifun's zip extension the unzips the file to the ASD and returns the filelist to the app. This is shown in the label display.

BLOCKS

We use the file component and a procedure to get the path to the ASD.

Messages are shown in the label to advise the user of progress.

Only one web component is used. Different "actions" are set, to enable different functions in the Web1.GotText event.