I have gotten started with the help of this thread, giving me a gsutil command:
gsutil notification create \
-t bucketcfpubsub -f json \
-e OBJECT_FINALIZE gs://bucketcfpubsub
With which I got this message published:
b'{\n "kind": "storage#object",\n "id": "bucketcfpubsub/test.txt/1544681756538155",\n "selfLink": "https://www.googleapis.com/storage/v1/b/bucketcfpubsub/o/test.txt",\n "name": "test.txt",\n "bucket": "bucketcfpubsub",\n "generation": "1544681756538155",\n "metageneration": "1",\n "contentType": "text/plain",\n "timeCreated": "2018-12-13T06:15:56.537Z",\n "updated": "2018-12-13T06:15:56.537Z",\n "storageClass": "STANDARD",\n "timeStorageClassUpdated": "2018-12-13T06:15:56.537Z",\n "size": "1938",\n "md5Hash": "sDSXIvkR/PBg4mHyIUIvww==",\n "mediaLink": "https://www.googleapis.com/download/storage/v1/b/bucketcfpubsub/o/test.txt?generation=1544681756538155&alt=media",\n "crc32c": "UDhyzw==",\n "etag": "CKvqjvuTnN8CEAE="\n}\n'
You can see it more 'readably' here
However, this documentation guide hints that we could trim that down to specific metadata that we're interested in. For example, the name of the file, with "objectId". But it doesn't exactly say how this can be implemented through gsutil. In the above wall of text, there is also "timeCreated" and "size".
I would like to set up a notification that outputs the name of the file uploaded as the MESSAGE, and timeCreated and size as attributes.
Could anyone please explain how the input code can be manipulated to achieve this?