A code example of how you can use Cloud Functions ( underlying powered by Cloud Run and therefore can also use Cloud Run ) to go through contents of a Google Cloud Storage (GCS) bucket, retrieve them and then zip up the entire content into a zip file to present for the user to download.
The overall steps in this workload is:
- Specify a GCS bucket or folder
- Download all files in the bucket or folder
- Add files to a zip file
- Upload the zip file back to the same GCS bucket (you can change the destination bucket if you want)
- Give the user the link to download the zip file from the GCS bucket
Because we are downloading files into memory first, this particular example works best for small file sizes. If the files in the GCS buckets are very large, you likely need some other implementation where you download the files to disk temporarily first.