【发布时间】:2019-05-14 08:30:29
【问题描述】:
在this thread 的帮助下,我已经开始使用 gsutil 命令:
gsutil notification create \
-t bucketcfpubsub -f json \
-e OBJECT_FINALIZE gs://bucketcfpubsub
我通过它发布了这条消息:
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'
你可以看到它更“可读”here
但是,this documentation guide 暗示我们可以将其缩减为我们感兴趣的特定元数据。例如,带有“objectId”的文件名。但它并没有确切说明如何通过 gsutil 实现这一点。在上面的文字墙中,还有“timeCreated”和“size”。
我想设置一个通知,将上传的文件名作为 MESSAGE 输出,并将 timeCreated 和 size 作为属性输出。
谁能解释一下如何操纵输入代码来实现这一点?
【问题讨论】:
标签: google-cloud-platform google-cloud-storage google-cloud-pubsub gsutil