mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
fix: recognize small text files (#531)
Former-commit-id: c4d7475d7fe858562fb5f45dc39164aac2463cbd [formerly da7f7862848b719e71b0b4af9fb4c9813a2c1629] [formerly 264f015d1a736fd5d237e7895d3ee142b0137cee [formerly a0194899c9
]]
Former-commit-id: 218bd162ee8f5222fdb0c717b481524c210ded7a [formerly 916f1ca36e2439e32d1b6a8baa0eee7a8efd290c]
Former-commit-id: ad2dd70b88612c8a212c0351abdeae9da442e21d
This commit is contained in:
parent
7e3a15e073
commit
b85a07536d
@ -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…
Reference in New Issue
Block a user