images.get_serving_url() does not work with cloud storage

178 views
Skip to first unread message

Suresh Jeevanandam

unread,
Sep 18, 2017, 2:14:57 PM9/18/17
to Google App Engine
I am trying to serve images stored in cloud storage from appengine python Standard environment.
I found the images.get_serving_url() to be the simplest way to do this after some research. But, unfortunately it did not work when deployed.

Here is the error message. Am I doing something wrong in this call. Or this method is not the correct one for this use. Is there any other simpler way to achieve this?

    return images.get_serving_url(None, filename='/gs/' + self.get_filename())
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/images/__init__.py", line 1868, in get_serving_url
    return rpc.get_result()
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 613, in get_result
    return self.__get_result_hook(self)
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/images/__init__.py", line 1972, in get_serving_url_hook
    raise _ToImagesError(e, readable_blob_key)
InvalidBlobKeyError: InvalidBlobKeyError: u'/gs//silver-device-834.appspot.com/previews/63e0609e-7147-496d-9418-c44bdb5b0456.jpg'

Yannick (Cloud Platform Support)

unread,
Sep 19, 2017, 11:44:15 AM9/19/17
to Google App Engine
Hello Suresh. The image service's get_serving_url is indeed the recommended method of serving images from Google Cloud Storage using your application.

As for the InvalidBlobKeyError, this is most likely caused by the double-slashes in '/gs//silver...'. The filename should be of the form "/gs/bucket_name/object_name". [1]

Suresh Jeevanandam

unread,
Sep 19, 2017, 2:32:19 PM9/19/17
to Google App Engine
Hi,
Thanks a lot.

Regards,
Suresh

Reply all
Reply to author
Forward
0 new messages