WebDAV: allow to define custom MIME type mappings

Fixes #1154

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-01-23 18:43:25 +01:00
parent 61199172d0
commit 2066ad7c83
11 changed files with 183 additions and 15 deletions

View File

@@ -84,6 +84,9 @@ type webDavFileInfo struct {
// ContentType implements webdav.ContentTyper interface
func (fi *webDavFileInfo) ContentType(ctx context.Context) (string, error) {
extension := path.Ext(fi.virtualPath)
if ctype, ok := customMimeTypeMapping[extension]; ok {
return ctype, nil
}
if extension == "" || extension == ".dat" {
return "application/octet-stream", nil
}