Serving videos from blobstore Google app engine

275 views Asked by At

I am developing a Google App Engine (Python) application and I have run into a bit of a problem. I have a video in my blobstore that I would like to serve in a <iframe> tag, but I just can't get the source url to enter into the tag's "src" field. I have had some success using the image api for google app engine (specifically the get_serving_url(Blobkey) method where the Blobkey is known) and while that works on the development server, as soon as I roll out the application, I get the following error:

File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/images/__init__.py", line 1794, 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 1892, in get_serving_url_hook
 raise _ToImagesError(e, readable_blob_key)
TransformationError

So my question is this: knowing the Blobkey of a video in my blobstore, how do I get the serving url to display the video in a <iframe> tag?

2

There are 2 answers

0
user3420681 On

Okay, I got it. I did a call from the website to the server and simply used self.send_blob to serve the video. So client side:

function showVideo (video_blobKey) {
    document.getElementById("Video").setAttribute("src", "/getVideo?key=" + video_blobKey);
}

and server side:

class getVideo (blobstore_handlers.BlobstoreDownloadHandler):
    def get(self):
        blob_key = self.request.get('key')
        self.send_blob(blob_key)
0
minou On

You can't. get_serving_url is for images and not video. Instead, store the video in Google Cloud Storage instead of in the Blobstore. You then have a URL that you can use.