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/.
You can set up Cloud Functions to execute in response to various scenarios by specifying a trigger for your function.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With