Google Pub/Sub 功能是否具有在上传后直接通知 Google App Engine 端点的能力?

Does Google Pub/Sub feature have some of capability to notify a Google App Engine endpoint directly after an upload?

我正在查看 Google Pub/Sub ( https://cloud.google.com/storage/docs/pubsub-notifications ) 的文档,但我没有看到 Pub/Sub 制作 [=27= 的方法] 在新文件上传到存储桶时调用 Google App Engine 端点。

这是正确的,还是我漏掉了什么?

它在文档中说有一种较旧的方法可能可以完成此操作:https://cloud.google.com/storage/docs/object-change-notification。但是我不确定使用可能会被弃用的东西是否是个好主意?

谢谢

GCS 的 Cloud Pub/Sub 支持非常适合这种情况。

首先,创建一个 Cloud Pub/Sub 主题并配置您的 GCS 存储桶以向其发送 OBJECT_FINALIZE 消息。您可以这样做:

$> gsutil notification create -f json \
       -t newTopicName \
       -e OBJECT_FINALIZE \
       gs://bucketName

接下来,将 Cloud Pub/Sub 订阅添加到您的 Cloud Pub/Sub 主题,该主题会将通知推送到您的 App Engine 端点。您可以在 UI 中执行此操作,或者您可以 运行 这样的命令:

$> gcloud alpha pubsub subscriptions create subscriptionName \
        --topic newTopicName \
        --push-endpoint https://myapp.appspot.com/_ah/push_handlers/myHandler

最后,配置您的 App Engine 应用程序以在 URL 处处理传入的推送事件。您可以在 Cloud Pub/Sub 的文档中阅读有关此方法的更多信息:https://cloud.google.com/pubsub/docs/push#app-engine-standard-endpoints