I am looking at the documentation for Google Pub/Sub ( https://cloud.google.com/storage/docs/pubsub-notifications ) and I don't see a way for Pub/Sub to make a RESTful call to a Google App Engine endpoint when a new file has been uploaded to a bucket.
Is this correct, or did I miss something?
It says in the documentation that there is an older way to probably accomplish this : https://cloud.google.com/storage/docs/object-change-notification . But I am not sure if it is a good idea to use something that might be deprecated down the line?
Thanks
GCS's Cloud Pub/Sub support works well for this case.
First, create a Cloud Pub/Sub topic and configure your GCS bucket to send it OBJECT_FINALIZE
messages. You can do so like this:
$> gsutil notification create -f json \
-t newTopicName \
-e OBJECT_FINALIZE \
gs://bucketName
Next, add a Cloud Pub/Sub subscription to your Cloud Pub/Sub topic which pushes notifications to your App Engine endpoint. You can do this in the UI, or you can run a command like this:
$> gcloud alpha pubsub subscriptions create subscriptionName \
--topic newTopicName \
--push-endpoint https://myapp.appspot.com/_ah/push_handlers/myHandler
Finally, configure your app engine app to handle incoming push events at that URL. You can read more about this approach in Cloud Pub/Sub's documentation: https://cloud.google.com/pubsub/docs/push#app-engine-standard-endpoints
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.