You need to define a ServeHandler, as described here:
https://developers.google.com/appengine/docs/python/blobstore/#Python_Serving_a_blob
For examples of the implementation, see Downloaded filename with Google App Engine Blobstore.
Question
I have various PDF documents as blobs in the App Engine blobstore. Now, I want to preview them on a HTML page. From various other questions, I figured the HTML setup should be:
<embed src="{{ url_to_my_pdf_blob }}" width="500" height="600">
While experimenting, I found that in the SDK the get_serving_url
function will not only work for images but will also work for PDF blobs. This approach unfortunately fails in production.
I looked at the example using blobstore_handlers.BlobstoreDownloadHandler
but could not figure out how to wire this to my view (my app is based on Django
, the HTML file with the preview is served by a Django view class).
How do I get the url of the blob?
Solution
You need to define a ServeHandler, as described here:
https://developers.google.com/appengine/docs/python/blobstore/#Python_Serving_a_blob
For examples of the implementation, see Downloaded filename with Google App Engine Blobstore.