Refactor file type functions

This commit is contained in:
Deluan
2022-12-23 11:32:39 -05:00
committed by Deluan Quintão
parent 9ec349dce0
commit 8c1cd9c273
10 changed files with 75 additions and 98 deletions
-23
View File
@@ -1,23 +0,0 @@
package utils
import (
"mime"
"path/filepath"
"strings"
)
var excludeAudioType = []string{
"audio/x-mpegurl",
"audio/x-scpls",
}
func IsAudioFile(filePath string) bool {
extension := filepath.Ext(filePath)
mimeType := mime.TypeByExtension(extension)
return !StringInSlice(mimeType, excludeAudioType) && strings.HasPrefix(mimeType, "audio/")
}
func IsImageFile(filePath string) bool {
extension := filepath.Ext(filePath)
return strings.HasPrefix(mime.TypeByExtension(extension), "image/")
}