Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lcaballero/mime
A Go lib that parse a loosely formatted file of mime-type to file extensions.
https://github.com/lcaballero/mime
Last synced: 23 days ago
JSON representation
A Go lib that parse a loosely formatted file of mime-type to file extensions.
- Host: GitHub
- URL: https://github.com/lcaballero/mime
- Owner: lcaballero
- License: epl-1.0
- Created: 2016-10-09T15:42:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-06T19:28:13.000Z (about 8 years ago)
- Last Synced: 2024-06-20T03:42:49.905Z (7 months ago)
- Language: Go
- Size: 13.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.org
- License: license
Awesome Lists containing this project
README
#+BEGIN_HTML
#+END_HTML* Overview
This lib parses a file containing a loosely separated list of pairs.
The pairs are those of mime-types to file extensions.** Usage
*** Installation
#+BEGIN_SRC go
go get github.com/lcaballero/mime
#+END_SRC*** Example Usage
After making a copy of mime-types.txt for your project and placing it
in a directory named `.file` the following code would parse the file
and make a map of extensions to mime-type.#+BEGIN_SRC go
bin, _ := ioutil.ReadFile(".file/mime-types.txt")
r := bytes.NewReader(bin)lookup, _ := mime.ParseExtensionsLookup(r)
mimeType, ok := lookup["jpeg"]// mimeType == 'image/jpeg' typically at this point
#+END_SRC** License
See License File.
The use and distribution terms for this software are covered by the
[[http://opensource.org/licenses/eclipse-1.0.txt][Eclipse Public License 1.0]], which can be found in the file ‘license’
at the root of this distribution. By using this software in any
fashion, you are agreeing to be bound by the terms of this
license. You must not remove this notice, or any other, from this
software.