Ankit Srivastava
Ankit Srivastava

Reputation: 31

How to Trigger particular extension file in cloud storage through google cloud functions

We have different kinds of files in our source system (.txt, .xls etc) and we are moving these files from a source system to a cloud storage bucket. As per the architecture cloud function should get triggered on specific file extension lets say .txt when it comes to a bucket, but on the contrary, the function is triggering on every extension file which is kept in a bucket. As per my knowledge in Azure, we have function.json file where we can write extension-specific constraint but how to go forward in GCP? ( we are using python runtime )

Upvotes: 2

Views: 1490

Answers (1)

Rafael Lemos
Rafael Lemos

Reputation: 5829

According to the Google Cloud Storage Triggers Documentation, there are 4 main types of triggers for Cloud Storage's Functions.

  • object.finalize - Triggered when a new object is created;
  • object.delete - Triggered when an object is permanently deleted;
  • object.archive - Triggered when a live version of an object is archived or deleted;
  • object.metadataUpdate - Triggered when the metadata of an existing object changes.

The conditions for triggering these cloud functions cannot be changed, and this means that it will indeed triggers every time an event of that type occurs and whatever conditions are needed to be checked afterwards, eg. check the file extention before executing an action, have to be checked by the cloud function itself.

Hope this helps.

Upvotes: 5

Related Questions