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/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"mime"
|
||||
"net"
|
||||
"net/http"
|
||||
"path"
|
||||
|
@ -197,8 +198,15 @@ func (fs *FileSystem) Upload(ctx context.Context, r *http.Request, rawPath strin
|
|||
} else {
|
||||
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{
|
||||
MIMEType: r.Header.Get("Content-Type"),
|
||||
MIMEType: mimeType,
|
||||
File: r.Body,
|
||||
Size: fileSize,
|
||||
Name: fileName,
|
||||
|
|
Loading…
Reference in New Issue