chore: Merge pull request #1021 from WntFlm/mimefix

fix(webdav): empty mimeType
pull/1047/head
Xhofe 2022-05-01 19:13:29 +08:00 committed by GitHub
commit 3b413c2ee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -7,13 +7,6 @@ package webdav
import ( import (
"context" "context"
"fmt" "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" "mime"
"net" "net"
"net/http" "net/http"
@ -21,6 +14,14 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"time" "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{} 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)) mimeTypeTmp := mime.TypeByExtension(path.Ext(fileName))
if mimeTypeTmp != "" { if mimeTypeTmp != "" {
mimeType = mimeTypeTmp mimeType = mimeTypeTmp
} else {
mimeType = "application/octet-stream"
} }
} }
fileData := model.FileStream{ fileData := model.FileStream{