mirror of
https://github.com/filebrowser/filebrowser.git
synced 2026-01-23 10:45:24 +00:00
fix: recognize small text files (#531)
This commit is contained in:
parent
43707a68cf
commit
a0194899c9
1 changed files with 2 additions and 2 deletions
|
|
@ -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") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue