gomime

package module
v0.0.0-...-8c5762b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: MIT Imports: 1 Imported by: 8

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
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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeByExtension

func TypeByExtension(extension string) string

TypeByExtension returns the content type based on the extension of the file

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL