MCPcopy Index your code
hub / github.com/TruthHun/BookStack / IsAllowUploadFileExt

Function IsAllowUploadFileExt

conf/enumerate.go:131–154  ·  view source on GitHub ↗

判断是否是允许商城的文件类型.

(ext string, typ ...string)

Source from the content-addressed store, hash-verified

129
130//判断是否是允许商城的文件类型.
131func IsAllowUploadFileExt(ext string, typ ...string) bool {
132 if len(typ) > 0 {
133 t := strings.ToLower(strings.TrimSpace(typ[0]))
134 if t == "audio" {
135 _, ok := AudioExt.Load(ext)
136 return ok
137 } else if t == "video" {
138 _, ok := VideoExt.Load(ext)
139 return ok
140 }
141 }
142
143 if strings.HasPrefix(ext, ".") {
144 ext = string(ext[1:])
145 }
146 exts := GetUploadFileExt()
147
148 for _, item := range exts {
149 if strings.EqualFold(item, ext) {
150 return true
151 }
152 }
153 return false
154}

Callers 1

UploadMethod · 0.92

Calls 2

stringFunction · 0.85
GetUploadFileExtFunction · 0.85

Tested by

no test coverage detected