mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2026-10-20 00:15:40 +00:00
26 lines
421 B
Go
26 lines
421 B
Go
package mime
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
//go:generate go run generator.go
|
|
var MimeTypes map[string]string = make(map[string]string, 0)
|
|
|
|
func GetMimeType(p string) string {
|
|
ext := filepath.Ext(p)
|
|
if ext != "" {
|
|
ext = ext[1:]
|
|
}
|
|
mType := MimeTypes[strings.ToLower(ext)]
|
|
if mType == "" {
|
|
return "application/octet-stream"
|
|
}
|
|
return mType
|
|
}
|
|
|
|
func AllMimeTypes() map[string]string {
|
|
return MimeTypes
|
|
}
|