MIMETypeFromReaderAt takes a ReaderAt, sniffs the beginning of it, and returns the MIME type if sniffed, else the empty string.
(ra io.ReaderAt)
| 209 | // MIMETypeFromReaderAt takes a ReaderAt, sniffs the beginning of it, |
| 210 | // and returns the MIME type if sniffed, else the empty string. |
| 211 | func 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. |
| 218 | type errReader struct{ err error } |