Documentation ¶
Overview ¶
Package magic implements MIME type sniffing of data based on the well-known "magic" number prefixes in the file.
Index ¶
- func HasExtension(filename string, extensions map[string]bool) bool
- func IsVideoFileName(filename string) bool
- func MIMEType(hdr []byte) string
- func MIMETypeByExtension(ext string) string
- func MIMETypeFromReader(r io.Reader) (mime string, reader io.Reader)
- func MIMETypeFromReaderAt(ra io.ReaderAt) (mime string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasExtension ¶
HasExtension returns whether the file extension of filename is among extensions. It is a case-insensitive lookup, optimized for the ASCII case.
func IsVideoFileName ¶
IsVideoFileName reports whether the filename has an extension associated with a video file format.
func MIMEType ¶
MIMEType returns the MIME type from the data in the provided header of the data. It returns the empty string if the MIME type can't be determined.
func MIMETypeByExtension ¶
MIMETypeByExtension calls mime.TypeByExtension, and removes optional parameters, to keep only the type and subtype.
func MIMETypeFromReader ¶
MIMETypeFromReader takes a reader, sniffs the beginning of it, and returns the mime (if sniffed, else "") and a new reader that's the concatenation of the bytes sniffed and the remaining reader.
func MIMETypeFromReaderAt ¶
MIMETypeFromReaderAt takes a ReaderAt, sniffs the beginning of it, and returns the MIME type if sniffed, else the empty string.
Types ¶
This section is empty.