detectMimeType 检测 MIME 类型
(path string)
| 311 | |
| 312 | // detectMimeType 检测 MIME 类型 |
| 313 | func 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 | } |