Skip to content

Commit

Permalink
fix: recognize small text files (filebrowser#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinglinwen authored and 1138-4EB committed Sep 8, 2018
1 parent 43707a6 commit a019489
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit a019489

Please sign in to comment.