Domanda

So come impostare intestazione Content-Disposition per le richieste dinamiche, ma come impostare per i file statici.

Il problema è che GAE java versione di produzione imposta automaticamente attaccamento Content-Disposition per le richieste di file statici (btw difetto Content-Disposition sviluppo locale è in linea), ma ho bisogno di impostarlo su in linea .

Ora, quando qualcuno tenta di aprire statica del browser file pdf si avvia automaticamente scaricare, invece di cercare di aprirlo in una nuova scheda.

È stato utile?

Soluzione 2

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/

Altri suggerimenti

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)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top