<p>关于如何获取有关对存储桶所做更改的通知,您还可以尝试以下几种方法:</p>
<ol>
<li><p>使用<a href="https://cloud.google.com/storage/docs/pubsub-notifications" rel="nofollow noreferrer">Pub/Sub</a>这是推荐的方式,发布/订阅通知将有关对bucket中对象所做更改的信息发送到发布/订阅,并以消息的形式将信息添加到您选择的发布/订阅主题中。在这里,您将找到一个<a href="https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/storage/cloud-client/notification_polling.py" rel="nofollow noreferrer">example using python</a>,就像您的例子一样,并使用其他方式,如<a href="https://cloud.google.com/storage/docs/reporting-changes#gsutil_1" rel="nofollow noreferrer">gsutil</a>、其他支持的语言或<a href="https://cloud.google.com/storage/docs/reporting-changes#rest-apis" rel="nofollow noreferrer">REST APIs</a></p>
</li>
<li><p><a href="https://cloud.google.com/storage/docs/object-change-notification" rel="nofollow noreferrer">Object change notification</a>with<a href="https://cloud.google.com/storage/docs/gsutil/commands/notification#watchbucket" rel="nofollow noreferrer">Watchbucket</a>:这将创建一个通知通道,将通知事件发送到给定bucket <a href="https://cloud.google.com/storage/docs/object-change-notification#_Watching" rel="nofollow noreferrer">using a gsutil command</a>的给定应用程序URL</p>
</li>
<li><p>云函数<a href="https://cloud.google.com/functions/docs/calling/storage#functions-calling-storage-tabs" rel="nofollow noreferrer">Google Cloud Storage Triggers</a>使用<a href="https://cloud.google.com/functions/docs/writing#event-driven_functions" rel="nofollow noreferrer">event-driven functions</a>处理来自Google云存储的事件,配置这些通知以触发对bucket对象创建、删除、存档和元数据更新中各种事件的响应。这里有一些关于如何实现它的<a href="https://cloud.google.com/functions/docs/tutorials/storage" rel="nofollow noreferrer">documentation</a></p>
</li>
<li><p>另一种方法是使用<a href="https://cloud.google.com/eventarc/docs/overview" rel="nofollow noreferrer">Eventarc</a>构建<a href="https://cloud.google.com/eventarc/docs/event-driven-architectures" rel="nofollow noreferrer">event-driven architectures</a>,它提供了一个标准化的解决方案来管理分离的微服务之间的状态更改流,称为事件。Eventarc将这些事件路由到云运行,同时为您管理交付、安全性、授权、可观察性和错误处理。这里有一篇关于如何实现它的文章</p>
</li>
</ol>
<p>在这里,您可以找到具有相同问题和答案的相关帖子:</p>
<ol>
<li>使用<a href="https://stackoverflow.com/questions/57891922/how-to-read-and-modify-a-csv-file-on-one-bucket-in-cloud-storage-and-save-the-re/57902312#:%7E:text=Add%20a%20comment-,1%20Answer,-Active">Storage-triggered Cloud Function</a></李>
<li>与<a href="https://stackoverflow.com/questions/49367662/how-to-get-the-most-recently-uploaded-blob-from-google-cloud-storage-bucket/49380322#:%7E:text=Add%20a%20comment-,1%20Answer,-Active">Object Change Notification and Cloud Pub/Sub Notifications for Cloud Storage</a>一起</李>
<li>用<a href="https://stackoverflow.com/questions/43074834/how-do-i-get-notified-when-an-object-is-uploaded-to-my-gcs-bucket#:%7E:text=Add%20a%20comment-,3%20Answers,-Active">Cloud Pub/Sub topic example</a>回答</李>
</ol>
<hr/>