mimetype: github.com/gabriel-vasile/mimetype Index | Files | Directories

package mimetype

import "github.com/gabriel-vasile/mimetype"

Package mimetype uses magic number signatures to detect the MIME type and extension of a file.

Index

Package Files

mime.go node.go tree.go

func Detect Uses

func Detect(in []byte) (mime, extension string)

Detect returns the MIME type and extension of the provided byte slice.

mime is always a valid MIME type, with application/octet-stream as fallback. extension is empty string if detected file format does not have an extension.

func DetectFile Uses

func DetectFile(file string) (mime, extension string, err error)

DetectFile returns the MIME type and extension of the provided file.

mime is always a valid MIME type, with application/octet-stream as fallback. extension is empty string if detection failed with an error or detected file format does not have an extension.

func DetectReader Uses

func DetectReader(r io.Reader) (mime, extension string, err error)

DetectReader returns the MIME type and extension of the byte slice read from the provided reader.

mime is always a valid MIME type, with application/octet-stream as fallback. extension is empty string if detection failed with an error or detected file format does not have an extension.

Directories

PathSynopsis
internal/jsonJSON value parser state machine.
internal/matchersPackage matchers holds the matching functions used to find mime types.

Package mimetype imports 3 packages (graph) and is imported by 33 packages. Updated 2019-09-15. Refresh now. Tools for package owners.