Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

README

        

#+BEGIN_HTML


GoDoc


#+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.