From 69f8d5a77e9392d5285fcc1c8d68659eac88c67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Behouba=20Manass=C3=A9?= Date: Mon, 8 Jul 2019 16:06:17 +0300 Subject: [PATCH] Content-Disposition HTTP header in mediaapi's responses added (#685) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should fix #628 I also Noticed that GET /_matrix/media/r0/download/{serverName}/{mediaId}/{fileName} is not yet implemented, but it should work for both. Signed-off-by: Kouamé Behouba Manassé behouba@gmail.com --- mediaapi/routing/download.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mediaapi/routing/download.go b/mediaapi/routing/download.go index 9c8f43c4..38c43636 100644 --- a/mediaapi/routing/download.go +++ b/mediaapi/routing/download.go @@ -305,6 +305,10 @@ func (r *downloadRequest) respondFromLocalFile( }).Info("Responding with file") responseFile = file responseMetadata = r.MediaMetadata + + if len(responseMetadata.UploadName) > 0 { + w.Header().Set("Content-Disposition", fmt.Sprintf(`inline; filename*=utf-8"%s"`, responseMetadata.UploadName)) + } } w.Header().Set("Content-Type", string(responseMetadata.ContentType))