webdav: add MIMEType to FileInfo

This commit is contained in:
Simon Ser
2020-01-21 22:43:13 +01:00
parent c673e7c7e7
commit 02d1a7dbe8
3 changed files with 24 additions and 27 deletions

View File

@@ -2,6 +2,7 @@ package webdav
import (
"io"
"mime"
"net/http"
"os"
"path"
@@ -38,6 +39,8 @@ func fileInfoFromOS(href string, fi os.FileInfo) *FileInfo {
Size: fi.Size(),
ModTime: fi.ModTime(),
IsDir: fi.IsDir(),
// TODO: fallback to http.DetectContentType?
MIMEType: mime.TypeByExtension(path.Ext(href)),
}
}