fix(webdav): set mime by ext if it's empty

This commit is contained in:
Noah Hsu
2022-10-09 19:29:55 +08:00
parent 30f992c6a8
commit 8c69260972
4 changed files with 16 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"io"
"io/ioutil"
"mime"
"os"
"path"
"path/filepath"
@ -136,3 +137,12 @@ func GetFileType(filename string) int {
}
return conf.UNKNOWN
}
func GetMimeType(name string) string {
ext := path.Ext(name)
m := mime.TypeByExtension(ext)
if m != "" {
return m
}
return "application/octet-stream"
}