typesniffer

package
v1.25.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MimeTypeImageSvg  = "image/svg+xml"
	MimeTypeImageAvif = "image/avif"

	MimeTypeApplicationOctetStream = "application/octet-stream"
)
View Source
const SniffContentSize = 1024

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 blob's type.

func DetectContentType

func DetectContentType(data []byte) SniffedType

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

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 a 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 detects if the content format is text family, including text/plain, text/html, text/css, etc.

func (SniffedType) IsTextPlain

func (ct SniffedType) IsTextPlain() bool

func (SniffedType) IsVideo

func (ct SniffedType) IsVideo() bool

IsVideo detects if data is a video format

Jump to

Keyboard shortcuts

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