mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 10:53:09 -06:00
Added Content-Disposition header in mediaapi's responses. matrix-org/dendrite#628
This commit is contained in:
parent
1e495d4578
commit
e5eac51d88
|
|
@ -305,6 +305,10 @@ func (r *downloadRequest) respondFromLocalFile(
|
||||||
}).Info("Responding with file")
|
}).Info("Responding with file")
|
||||||
responseFile = file
|
responseFile = file
|
||||||
responseMetadata = r.MediaMetadata
|
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))
|
w.Header().Set("Content-Type", string(responseMetadata.ContentType))
|
||||||
|
|
@ -316,10 +320,6 @@ func (r *downloadRequest) respondFromLocalFile(
|
||||||
" object-src 'self';"
|
" object-src 'self';"
|
||||||
w.Header().Set("Content-Security-Policy", contentSecurityPolicy)
|
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 {
|
if _, err := io.Copy(w, responseFile); err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to copy from cache")
|
return nil, errors.Wrap(err, "failed to copy from cache")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue