google-cloud – How to Trigger an Event After Saving a Chosen CSV File in Google Cloud Storage Bucket

copyfilesgoogle-cloud-platformgoogle-cloud-storage

Trying to make a synchronous pipeline, I need to copy a csv file from Google Cloud Storage after it has been saved in Google Cloud Storage. The copy job does not have to be triggered right after the saving, it can also happen within some time frame at least. It just may not happen before the file has been saved. Therefore, either a trigger event or a cronjob are possible, or you may suggest something else.

How can I trigger copying a chosen csv file after it has been saved in Google Cloud Storage? Can I use a Cloud Function to do the copy job or are there other ways?

Best Answer

You can use the google.storage.object.finalize trigger for your Cloud Function which is going to respond to object creation events (uploading files to a bucket).

To include a piece of code that would copy the file, refer to the Cloud Storage docs for examples.