namiyousef
namiyousef

Reputation: 55

Custom message attributes on default GCS events

I was wondering if it's possible to customise the pubsub messages that are triggered by GCS events. In particular, I'm interested in adding metadata in the message "attributes".

For example, upon the creation of a new object in GCS, the OBJECT_FINALIZED (see https://cloud.google.com/functions/docs/calling/storage) is triggered.

I pull this message, e.g.

received_messages = pubsub_v1.SubscriberClient().pull(request)
for msg in received_messages:
   message_data = json.loads(msg.message.data.decode('utf-8')).get("data")
   msg_attributes = message_data.get("attributes") 

I want to be able to customise what goes into "attributes" prior to creation the object in GCS.

Upvotes: 0

Views: 581

Answers (1)

Samarth Singal
Samarth Singal

Reputation: 356

It is not possible to customize the Pub/Sub notifications from Cloud Storage. They are published by Cloud Storage and the schema and contents are controlled by the service and are specified in the notifications documentation.

Upvotes: 1

Related Questions