Search code examples
javagoogle-app-enginecontent-dispositionstatic-files

How to set content-disposition to inline for static file(s) in java Google App Engine


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.


Solution

  • 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/