Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to configure the cloud function trigger be a on a folder level for GCS bucket? [duplicate]

For example, imagine we have the following:

gs://a_bucket/a_folder Instead of setting trigger at gs://a_bucket when deploying, I need to set it at the folder level i.e. --trigger-bucket gs://a_bucket/a_folder/.

like image 879
DataVishesh Avatar asked Jan 25 '19 10:01

DataVishesh


People also ask

Can a cloud function trigger another cloud function?

You can set up Cloud Functions to execute in response to various scenarios by specifying a trigger for your function.


1 Answers

This is not possible. Try to create the Cloud Function from the Google Cloud Console. When choosing the bucket from the buckets list, you will realize that the folders and files are grayed out. Which means that you can't pick a folder for the trigger. You can only choose the bucket.

As a workaround, you can check every new file that is being uploaded to the bucket and get the path. It will indicate in which folder it was uploaded and you can check the folder with an if statement and perform actions there.

I did a little bit of coding myself and you can see my example code in GitHub. The main function is being triggered by the event and then it uses two extra functions to retrieve the file's path and the file's name.

like image 153
Andrei Cusnir Avatar answered Sep 18 '22 22:09

Andrei Cusnir