mirror of https://github.com/Xhofe/alist
fix(webdav): wrong MIMEType (close #1007)
parent
f77ea1b3a5
commit
75c98429bf
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/Xhofe/alist/server/common"
|
"github.com/Xhofe/alist/server/common"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"mime"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
@ -197,8 +198,15 @@ func (fs *FileSystem) Upload(ctx context.Context, r *http.Request, rawPath strin
|
||||||
} else {
|
} else {
|
||||||
delete(upFileMap, rawPath)
|
delete(upFileMap, rawPath)
|
||||||
}
|
}
|
||||||
|
mimeType := r.Header.Get("Content-Type")
|
||||||
|
if mimeType == "" || strings.ToLower(mimeType) == "application/octet-stream" {
|
||||||
|
mimeTypeTmp := mime.TypeByExtension(path.Ext(fileName))
|
||||||
|
if mimeTypeTmp != "" {
|
||||||
|
mimeType = mimeTypeTmp
|
||||||
|
}
|
||||||
|
}
|
||||||
fileData := model.FileStream{
|
fileData := model.FileStream{
|
||||||
MIMEType: r.Header.Get("Content-Type"),
|
MIMEType: mimeType,
|
||||||
File: r.Body,
|
File: r.Body,
|
||||||
Size: fileSize,
|
Size: fileSize,
|
||||||
Name: fileName,
|
Name: fileName,
|
||||||
|
|
Loading…
Reference in New Issue