From 658fd5ad6e8a6cfe519b94eea6fec142f0d08fd8 Mon Sep 17 00:00:00 2001 From: WntFlm Date: Sun, 1 May 2022 09:39:49 +0800 Subject: [PATCH] fix(webdav): empty mimeType Now mimeType will always be a non-empty string, by defaulting it to "application/octet-stream". --- server/webdav/file.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/server/webdav/file.go b/server/webdav/file.go index cdb89802..d4f8d50d 100644 --- a/server/webdav/file.go +++ b/server/webdav/file.go @@ -7,13 +7,6 @@ package webdav import ( "context" "fmt" - "github.com/Xhofe/alist/conf" - "github.com/Xhofe/alist/drivers/base" - "github.com/Xhofe/alist/drivers/operate" - "github.com/Xhofe/alist/model" - "github.com/Xhofe/alist/server/common" - "github.com/Xhofe/alist/utils" - log "github.com/sirupsen/logrus" "mime" "net" "net/http" @@ -21,6 +14,14 @@ import ( "path/filepath" "strings" "time" + + "github.com/Xhofe/alist/conf" + "github.com/Xhofe/alist/drivers/base" + "github.com/Xhofe/alist/drivers/operate" + "github.com/Xhofe/alist/model" + "github.com/Xhofe/alist/server/common" + "github.com/Xhofe/alist/utils" + log "github.com/sirupsen/logrus" ) type FileSystem struct{} @@ -203,6 +204,8 @@ func (fs *FileSystem) Upload(ctx context.Context, r *http.Request, rawPath strin mimeTypeTmp := mime.TypeByExtension(path.Ext(fileName)) if mimeTypeTmp != "" { mimeType = mimeTypeTmp + } else { + mimeType = "application/octet-stream" } } fileData := model.FileStream{