yinbangzhong 2 년 전
부모
커밋
9f78e3b126
2개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 2
      controllers/audio.go
  2. 2 2
      service/process.go

+ 2 - 2
controllers/audio.go

@@ -64,7 +64,7 @@ func (slf AudioCtl) Upload(c *gin.Context) {
 			util.ResponseFormat(c, code.RequestParamError, "上传失败")
 			return
 		}
-		if filepath.Ext(filename) == ".mp3" || filepath.Ext(filename) == ".wav" {
+		if strings.ToLower(filepath.Ext(filename)) == ".mp3" || strings.ToLower(filepath.Ext(filename)) == ".wav" {
 			timeStr := arr[4] + strings.Split(arr[5], ".")[0]
 			t, err := time.ParseInLocation("20060102150405", timeStr, time.Local)
 			if err != nil {
@@ -82,7 +82,7 @@ func (slf AudioCtl) Upload(c *gin.Context) {
 			audio.OccurrenceAt = t
 			audio.IsFollowed = 0
 		}
-		if filepath.Ext(filename) == ".txt" {
+		if strings.ToLower(filepath.Ext(filename)) == ".txt" {
 			audio.TxtFilePath = filePath
 			//读取filepath文件内容到bts
 			bts, err := os.ReadFile(filePath)

+ 2 - 2
service/process.go

@@ -319,10 +319,10 @@ FOR:
 					audio := &models.Audio{}
 					isOk := true
 					// 判断文件类型是否为.mp3或.wav
-					if filepath.Ext(event.Name) == ".mp3" || filepath.Ext(event.Name) == ".wav" {
+					if strings.ToLower(filepath.Ext(event.Name)) == ".mp3" || strings.ToLower(filepath.Ext(event.Name)) == ".wav" {
 						isOk = audoF(event.Name, fileName, audio) && txtF(pair[name], audio)
 					}
-					if filepath.Ext(event.Name) == ".txt" {
+					if strings.ToLower(filepath.Ext(event.Name)) == ".txt" {
 						isOk = audoF(pair[name], filepath.Base(pair[name]), audio) && txtF(event.Name, audio)
 					}
 					if !isOk {