typesniffer

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// SvgMimeType MIME type of SVG images.
	SvgMimeType = "image/svg+xml"
	// ApplicationOctetStream MIME type of binary files.
	ApplicationOctetStream = "application/octet-stream"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SniffedType

type SniffedType struct {
	// contains filtered or unexported fields
}

SniffedType contains information about a blobs type.

func DetectContentType

func DetectContentType(data []byte) SniffedType

DetectContentType extends http.DetectContentType with more content types. Defaults to text/unknown if input is empty.

func DetectContentTypeFromReader

func DetectContentTypeFromReader(r io.Reader) (SniffedType, error)

DetectContentTypeFromReader guesses the content type contained in the reader.

func (SniffedType) GetMimeType added in v1.17.0

func (ct SniffedType) GetMimeType() string

GetMimeType returns the mime type

func (SniffedType) IsAudio

func (ct SniffedType) IsAudio() bool

IsAudio detects if data is an video format

func (SniffedType) IsBrowsableBinaryType added in v1.17.0

func (ct SniffedType) IsBrowsableBinaryType() bool

IsBrowsableBinaryType returns whether a non-text type can be displayed in a browser

func (SniffedType) IsImage

func (ct SniffedType) IsImage() bool

IsImage detects if data is an image format

func (SniffedType) IsPDF

func (ct SniffedType) IsPDF() bool

IsPDF detects if data is a PDF format

func (SniffedType) IsRepresentableAsText

func (ct SniffedType) IsRepresentableAsText() bool

IsRepresentableAsText returns true if file content can be represented as plain text or is empty.

func (SniffedType) IsSvgImage

func (ct SniffedType) IsSvgImage() bool

IsSvgImage detects if data is an SVG image format

func (SniffedType) IsText

func (ct SniffedType) IsText() bool

IsText etects if content format is plain text.

func (SniffedType) IsVideo

func (ct SniffedType) IsVideo() bool

IsVideo detects if data is an video format

Jump to

Keyboard shortcuts

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