[lectures] Fix content type detection.
This commit is contained in:
parent
9944c84b9d
commit
49be410e05
1 changed files with 1 additions and 2 deletions
|
@ -39,8 +39,7 @@ func copyHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
defer func() { _ = f.Close() }()
|
defer func() { _ = f.Close() }()
|
||||||
|
|
||||||
// Infer the Content-Type of the file.
|
// Infer the Content-Type of the file.
|
||||||
filePrefix := make([]byte, 1024)
|
filePrefix, _ := io.ReadAll(io.LimitReader(f, 512))
|
||||||
_, _ = io.ReadAtLeast(f, filePrefix, 512)
|
|
||||||
contentType := http.DetectContentType(filePrefix)
|
contentType := http.DetectContentType(filePrefix)
|
||||||
|
|
||||||
// Get the file size.
|
// Get the file size.
|
||||||
|
|
Loading…
Reference in a new issue