0
votes

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

1
Maybe you can use a cloud function as an intermediary then? Have it call your endpoint when a change event is thrown?Dries De Rydt
Hi @DriesDeRydt , thanks for the reply, cloud function looks like it might work, but do you also have any opinion on using Object Change Notification? It seems to do what Google PubSub and Cloud Function's job in one stepuser1805458

1 Answers

1
votes

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