MCPcopy Index your code
hub / github.com/perkeep/perkeep / MIMETypeFromReaderAt

Function MIMETypeFromReaderAt

internal/magic/magic.go:211–215  ·  view source on GitHub ↗

MIMETypeFromReaderAt takes a ReaderAt, sniffs the beginning of it, and returns the MIME type if sniffed, else the empty string.

(ra io.ReaderAt)

Source from the content-addressed store, hash-verified

209// MIMETypeFromReaderAt takes a ReaderAt, sniffs the beginning of it,
210// and returns the MIME type if sniffed, else the empty string.
211func MIMETypeFromReaderAt(ra io.ReaderAt) (mime string) {
212 var buf [1024]byte
213 n, _ := ra.ReadAt(buf[:], 0)
214 return MIMEType(buf[:n])
215}
216
217// errReader is an io.Reader which just returns err.
218type errReader struct{ err error }

Callers 1

fileInfoMethod · 0.92

Calls 2

MIMETypeFunction · 0.85
ReadAtMethod · 0.45

Tested by

no test coverage detected