MCPcopy Create free account
hub / github.com/astercloud/aster / detectMimeType

Function detectMimeType

pkg/media/types.go:313–331  ·  view source on GitHub ↗

detectMimeType 检测 MIME 类型

(path string)

Source from the content-addressed store, hash-verified

311
312// detectMimeType 检测 MIME 类型
313func detectMimeType(path string) string {
314 ext := strings.ToLower(filepath.Ext(path))
315 switch ext {
316 case ".txt":
317 return "text/plain"
318 case ".pdf":
319 return "application/pdf"
320 case ".json":
321 return "application/json"
322 case ".xml":
323 return "application/xml"
324 case ".csv":
325 return "text/csv"
326 case ".zip":
327 return "application/zip"
328 default:
329 return "application/octet-stream"
330 }
331}

Callers 1

NewFileFromPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected