diff --git a/pkg/server/download.go b/pkg/server/download.go index 6b342fc24..efd75474f 100644 --- a/pkg/server/download.go +++ b/pkg/server/download.go @@ -66,7 +66,8 @@ type DownloadHandler struct { // to get at a wholeref more efficiently. (e.g. blobpacked) Search *search.Handler - ForceMIME string // optional + ForceMIME string // optional + forceInline bool // to force Content-Disposition to inline, when it was not set in the request // pathByRef maps a file Ref to the path of the file, relative to its ancestor // directory which was requested for download. It is populated by checkFiles, which @@ -329,7 +330,7 @@ func (dh *DownloadHandler) ServeFile(w http.ResponseWriter, r *http.Request, fil return "file-" + file.String() + ext } - if r.FormValue("inline") == "1" { + if r.FormValue("inline") == "1" || dh.forceInline { // TODO(mpl): investigate why at least text files have an incorrect MIME. if fi.mime == "application/octet-stream" { // Since e.g. plain text files are seen as "application/octet-stream", we force diff --git a/pkg/server/share.go b/pkg/server/share.go index ee0685a39..f8792e5b6 100644 --- a/pkg/server/share.go +++ b/pkg/server/share.go @@ -265,7 +265,8 @@ func (h *shareHandler) handleGetViaSharing(rw http.ResponseWriter, req *http.Req return unauthorized(assembleNonTransitive, "Cannot assemble non-transitive share") } dh := &DownloadHandler{ - Fetcher: h.fetcher, + Fetcher: h.fetcher, + forceInline: true, // TODO(aa): It would be nice to specify a local cache here, as the UI handler does. } dh.ServeFile(rw, req, blobRef)