MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / IsBinaryPreviewFile

Function IsBinaryPreviewFile

agent/utils/files/fileinfo.go:506–532  ·  view source on GitHub ↗
(mimeType, extension string)

Source from the content-addressed store, hash-verified

504}
505
506func IsBinaryPreviewFile(mimeType, extension string) bool {
507 mimeType = strings.ToLower(strings.TrimSpace(mimeType))
508 extension = strings.ToLower(strings.TrimSpace(extension))
509
510 if mimeType == "" || mimeType == "application/octet-stream" {
511 _, ok := binaryPreviewExtensions[extension]
512 return ok
513 }
514
515 if strings.HasPrefix(mimeType, "text/") {
516 return false
517 }
518
519 for _, prefix := range binaryPreviewMimePrefixes {
520 if strings.HasPrefix(mimeType, prefix) {
521 return true
522 }
523 }
524
525 _, ok := binaryPreviewMimeTypes[mimeType]
526 if ok {
527 return true
528 }
529
530 _, ok = binaryPreviewExtensions[extension]
531 return ok
532}
533
534func DetectBinary(buf []byte) bool {
535 mimeType := http.DetectContentType(buf)

Callers 2

getContentMethod · 0.85
DetectBinaryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected