3

I'm trying to use GAE image service, but I have encountered a problem.

I have two projects. Project A has GAE, and Project B has GCS bucket. This is because the GAE region can not be changed once the project is created.

When get_serving_url is called from the GAE to the object of the GCS bucket, the following exception occurs.

Traceback (most recent call last):
  ...
  File "/base/data/home/apps/b~[PROJECT_NAME]/20161215t131056.397760967541775314/main.py", line 125, in _get_serving_url
    return get_serving_url(blob_key)
  File "/base/data/home/runtimes/python27/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/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/python27_lib/versions/1/google/appengine/api/images/__init__.py", line 1972, in get_serving_url_hook
    raise _ToImagesError(e, readable_blob_key)
TransformationError

When putting them in the same project this exception will not be thrown. GAE's service account and project A have full access to buckets and objects.

Is there anything else I need to try?


Self-solving

I founds cause in the docs of Image API in GAE/Java.

Important: If you serve images from Google Cloud Storage, you cannot serve an image from two separate apps. Only the first app that calls getServingUrl on the image can get the URL to serve it because that app has obtained ownership of the image. Any other app that subsequently calls getServingUrl on the image will therefore be unsuccessful. If a second app needs to serve the image, the app needs to first copy the image and then invoke getServingUrl on the copy.

I used objects of the bucket from another project simultaneously.

Consequently, I have verified get_serving_url correctly.

apstndb
  • 301
  • 2
  • 10

1 Answers1

0

You do not have to use a serving url. You can serve files grom GCS:

https://storage.googleapis.com/your_bucket/your_filename

or SDK http://localhost:8080/_ah/gcs/your_bucket/your_filename

voscausa
  • 11,253
  • 2
  • 39
  • 67