fix: /api/upload-resource panics when parsing file_type (#2046)

This commit is contained in:
WintBit 2023-07-07 16:18:25 +08:00 committed by GitHub
parent 9511fae9d9
commit 68417a2d7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -229,12 +229,12 @@ func (c *ApiController) UploadResource() {
fileType := "unknown"
contentType := header.Header.Get("Content-Type")
fileType, _ = util.GetOwnerAndNameFromId(contentType)
fileType, _ = util.GetOwnerAndNameFromIdNoCheck(contentType + "/")
if fileType != "image" && fileType != "video" {
ext := filepath.Ext(filename)
mimeType := mime.TypeByExtension(ext)
fileType, _ = util.GetOwnerAndNameFromId(mimeType)
fileType, _ = util.GetOwnerAndNameFromIdNoCheck(mimeType + "/")
}
fullFilePath = object.GetTruncatedPath(provider, fullFilePath, 175)