mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-08 07:23:10 -06:00
mediaapi/writers/upload: Generate Content-Disposition if not set
This commit is contained in:
parent
9d9b23e8e4
commit
911b5dc170
|
|
@ -21,6 +21,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
|
@ -127,12 +128,16 @@ func Upload(req *http.Request, cfg config.MediaAPI, db *storage.Database) util.J
|
|||
},
|
||||
}
|
||||
|
||||
// FIXME: if no Content-Disposition then set
|
||||
|
||||
if resErr = r.Validate(cfg.MaxFileSize); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
if len(r.MediaMetadata.UploadName) > 0 {
|
||||
r.MediaMetadata.ContentDisposition = types.ContentDisposition(
|
||||
"inline; filename*=utf-8''" + url.PathEscape(string(r.MediaMetadata.UploadName)),
|
||||
)
|
||||
}
|
||||
|
||||
logger.WithFields(log.Fields{
|
||||
"Origin": r.MediaMetadata.Origin,
|
||||
"UploadName": r.MediaMetadata.UploadName,
|
||||
|
|
|
|||
Loading…
Reference in a new issue