0
votes

Is there any way to create a handler with signed urls in Google Cloud Storage with Google App Engine (Java)?

I can successfully upload files to buckets with signed URLs in my Android (Java) app but I have no current way of executing additional code server-side upon upload completion.

I have been messing around with the Blobstore API and by creating upload urls that are handled by a servlet in app engine but I can't seem to make it work inside my Cloud Endpoints App Engine project.

Also, signed urls seem favorable to me because I can set expiration times on them.

1
There are object change notifications (cloud.google.com/storage/docs/object-change-notification) if you remember the signed url you created it should be possible to filter out the events you're not interested in.konqi
@konqi Are these meant to be used in place of upload handlers in GCS?Micro
Meant to be? I don't know. Possible: yes.konqi
@konqi I think it was meant to be. Works like a charm. Thanks for confirming this for me.Micro

1 Answers

0
votes

Looks like the only way to do this right now is with object change notifications. Which actually isn't that bad.

I set up a servlet in my Cloud Endpoints App Engine project and in it's doPost() I read in the json body of the request, and parsing it you get all the information you need: https://cloud.google.com/storage/docs/object-change-notification#_Type_AddUpdateDel

Keep in mind this warning from the docs though:

Because of the retry mechanism above, it is possible that notifications are delivered more than once. Ensure that your application is idempotent with respect to processing a unique notification.

So make sure whatever operations you are taking after a notification is sent is idempotent (e.g. doing the operation more than once does not affect the first result of the operation)