Last active
May 14, 2021 17:24
-
-
Save tarlen5/5236cbba6fe5f651889c55098d4db47c to your computer and use it in GitHub Desktop.
Cloud Function Accessing ObjectId of Pubsub Notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run(event, context): | |
""" | |
Sample code of a cloud function entrypoint that is called when a message | |
is published to a topic. This is run when there is a notification on a prefix | |
in cloud storage. | |
The message (event) contains the path to the objectId invoking the message. | |
""" | |
event_filename = event["attributes"]["objectId"] | |
event_bucket = event["attributes"]["bucketId"] | |
print("file `{}` was triggered in bucket `{}`".format(event_filename, event_bucket)) | |
print("This Function was triggered by messageId {} published at {}".format( | |
context.event_id, context.timestamp)) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment