Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Functions: zip multiple documents from Cloud Storage

I already searched through a lot of questions on stack overflow but couldn't find a fitting answer from which I can derive the answer I need:

I want to zip multiple files from a folder within Google Cloud Storage/Firebase Storage with a Cloud Function.

I already found the solution for zipping documents from the local filesystem but could not derive how to do it within a Cloud Function for Cloud Storage.

like image 949
ktm125 Avatar asked Sep 11 '25 16:09

ktm125


1 Answers

Google Cloud Storage supports the decompressive form of transcoding but not a compressive form of transcoding. However, at Cloud Storage, any user can store a gzip-compressed file.

To zip multiple documents from Cloud Storage using Cloud Functions, you can download the files from Cloud Storage to functions instances using gcs.bucket.file(filePath). download, zip the file, and re-upload the files to the Cloud Storage. Here you will find an example of downloading, transforming, and uploading a file. You can find an example to zip multiple files in this StackOverflow thread. This document explains how you can upload objects to Cloud Storage using Console, Gsutil, Code Sample, or REST APIs.

like image 66
Mohammad I Avatar answered Sep 15 '25 21:09

Mohammad I