diff --git a/receive.go b/receive.go index 2771bd7..8a714b1 100644 --- a/receive.go +++ b/receive.go @@ -113,6 +113,7 @@ func (a *app) receiveFile(c *fasthttp.RequestCtx) { func receiveObject(c *fasthttp.RequestCtx, cli object.Service_GetClient) error { var ( typ string + content_disp_type string put = c.Request.URI().QueryArgs().GetBool("download") ) @@ -138,9 +139,12 @@ func receiveObject(c *fasthttp.RequestCtx, cli object.Service_GetClient) error { if hdr := obj.Headers[i].GetUserHeader(); hdr != nil { c.Response.Header.Set("x-"+hdr.Key, hdr.Value) - if hdr.Key == object.FilenameHeader && put { + if hdr.Key == object.FilenameHeader { + if put { + content_disp_type = "attachment" + } else { content_disp_type = "inline"} // NOTE: we use path.Base because hdr.Value can be something like `/path/to/filename.ext` - c.Response.Header.Set("Content-Disposition", "attachment; filename="+path.Base(hdr.Value)) + c.Response.Header.Set("Content-Disposition", content_disp_type+"; filename="+path.Base(hdr.Value)) } } }