0

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?

Roger
  • 4,737
  • 4
  • 43
  • 68
  • What do you mean by "fails in production"? I migrated my files to GCS, but before that I used the Blobstore, and it worked perfectly fine. – Andrei Volgin May 08 '14 at 22:05
  • I mean it will not work when deployed to Google App Engine. It fails with a TransformationError (which is understandable as it is not an image but a PDF). – Roger May 08 '14 at 22:08
  • Did you try multiple inheritance? Or use GCS to create a serving url, without the image API. – voscausa May 08 '14 at 23:25
  • Why would you use the Image API for PDF files? Do not use it, and the Blobstore will serve your PDFs with no problems. – Andrei Volgin May 09 '14 at 00:05
  • @AndreiVolgin I don't. I was just experimenting. As per my question, how do I get the url of the PDF??? – Roger May 09 '14 at 00:09

1 Answers1

1

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.

Community
  • 1
  • 1
Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58