https://github.com/cubewise-code/go-mime
Get the mime type / content type of a file from its extension without external dependencies
https://github.com/cubewise-code/go-mime
content-type go golang mime mime-types
Last synced: 5 months ago
JSON representation
Get the mime type / content type of a file from its extension without external dependencies
- Host: GitHub
- URL: https://github.com/cubewise-code/go-mime
- Owner: cubewise-code
- License: mit
- Created: 2019-03-22T01:34:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-26T16:54:05.000Z (over 3 years ago)
- Last Synced: 2024-06-18T15:41:06.395Z (about 2 years ago)
- Topics: content-type, go, golang, mime, mime-types
- Language: Go
- Size: 26.4 KB
- Stars: 22
- Watchers: 3
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mime
Get the mime type / content type of a file from its extension without external dependencies
# Usage
```
go get github.com/cubewise-code/go-mime
```
```go
import (
"github.com/cubewise-code/go-mime"
)
// Get the file extension
ext := filepath.Ext(fileName)
// An empty string is returned if the extension is not found
contentType := gomime.TypeByExtension(ext)
```
# Why
We wanted a simple mime library that gives a consistent result on each environment. The golang mime package (https://golang.org/pkg/mime/) loads the list of mime types using the OS, meaning you get a different list depending on OS and OS version. On Windows this depends on the programs installed and whether the user running the process has access to the registry.
# Mime Source
The mime list are sourced from here: https://github.com/micnic/mime.json