3
votes

I know how to set content-disposition header for dynamic requests, but how to set it for static files.

Problem is that GAE java production version automatically sets to attachment content-disposition for static file requests (btw default local development content-disposition is inline), but I need to set it to inline.

Now when somebody tries to open static pdf file browser automatically starts download instead to try to open it in new tab.

2

2 Answers

1
votes

Besides mime type and expiration, you don't have much control over how static files are served (see Google app.yaml documentation). If you need fine-grained control, you can store the PDF in the Datastore as a Blob and write a handler for it.

(Not to be confused with the Blobstore API)

1
votes

All my pdf files are under /pdf/ path. I have created web request for /pdfi/ uri that with url fetch service fetches requested file under /pdf/ path and sets content-disposition to inline.

Now where ever (static html, etc.) there was link for any pdf file I have replaced /pdf/ with /pdfi/ and everything works. When and if GAE team allow us to set content-disposition for static files I will simply change every link from /pdfi/ to /pdf/