[lectures] Fix content type detection.

This commit is contained in:
Arseny Balobanov 2022-04-21 21:38:22 +03:00
parent 9944c84b9d
commit 49be410e05

View file

@ -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.