mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 23:13:11 -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"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"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 {
|
if resErr = r.Validate(cfg.MaxFileSize); resErr != nil {
|
||||||
return *resErr
|
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{
|
logger.WithFields(log.Fields{
|
||||||
"Origin": r.MediaMetadata.Origin,
|
"Origin": r.MediaMetadata.Origin,
|
||||||
"UploadName": r.MediaMetadata.UploadName,
|
"UploadName": r.MediaMetadata.UploadName,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue