package manager
import (
"mime"
"path"
)
//初始化数据
func init() {
if mime.TypeByExtension(".txt") == "" {
panic("mime.types not found")
}
}
//获取文件扩展名对应的媒体(内容)类型
func get_content_type(filepath string) string {
content_type := "application/octet-stream"
ext := path.Ext(filepath)
if ext != "" && ext != "." {
content_type_ := mime.TypeByExtension(ext)
if content_type_ != "" {
content_type = content_type_
}
}
return content_type
}