fix: recognize small text files (#531)

pull/358/head
chinglin 2018-09-09 02:01:41 +08:00 committed by 1138-4EB
parent 43707a68cf
commit a0194899c9
1 changed files with 2 additions and 2 deletions

View File

@ -223,14 +223,14 @@ func (i *File) GetFileType(checkContent bool) error {
// Only the first 512 bytes are used to sniff the content type.
buffer := make([]byte, 512)
_, err = file.Read(buffer)
n, err := file.Read(buffer)
if err != nil && err != io.EOF {
return err
}
// Tries to get the file mimetype using its first
// 512 bytes.
mimetype = http.DetectContentType(buffer)
mimetype = http.DetectContentType(buffer[:n])
}
if strings.HasPrefix(mimetype, "video") {