fix: recognize small text files (#531)
parent
43707a68cf
commit
a0194899c9
|
@ -223,14 +223,14 @@ func (i *File) GetFileType(checkContent bool) error {
|
||||||
|
|
||||||
// Only the first 512 bytes are used to sniff the content type.
|
// Only the first 512 bytes are used to sniff the content type.
|
||||||
buffer := make([]byte, 512)
|
buffer := make([]byte, 512)
|
||||||
_, err = file.Read(buffer)
|
n, err := file.Read(buffer)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tries to get the file mimetype using its first
|
// Tries to get the file mimetype using its first
|
||||||
// 512 bytes.
|
// 512 bytes.
|
||||||
mimetype = http.DetectContentType(buffer)
|
mimetype = http.DetectContentType(buffer[:n])
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(mimetype, "video") {
|
if strings.HasPrefix(mimetype, "video") {
|
||||||
|
|
Loading…
Reference in New Issue