diff --git a/src/github.com/matrix-org/dendrite/mediaapi/routing/download.go b/src/github.com/matrix-org/dendrite/mediaapi/routing/download.go index 4a1516e1f..38c436367 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/routing/download.go +++ b/src/github.com/matrix-org/dendrite/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)) @@ -316,10 +320,6 @@ func (r *downloadRequest) respondFromLocalFile( " object-src 'self';" w.Header().Set("Content-Security-Policy", contentSecurityPolicy) - if len(responseMetadata.UploadName) > 0 && !r.IsThumbnailRequest { - w.Header().Set("Content-Disposition", fmt.Sprintf(`inline; filename*=utf-8"%s"`, responseMetadata.UploadName)) - } - if _, err := io.Copy(w, responseFile); err != nil { return nil, errors.Wrap(err, "failed to copy from cache") }