Fix cover content type detection build error

This commit is contained in:
Arne
2026-08-06 20:42:42 +02:00
parent b163aade71
commit 6b42ab0dd6
+3 -10
View File
@@ -2,12 +2,12 @@ package library
import (
"archive/zip"
"bytes"
"crypto/sha1"
"encoding/hex"
"encoding/xml"
"fmt"
"io"
"net/http"
"os"
"path"
"path/filepath"
@@ -288,8 +288,9 @@ func readZipFile(files []*zip.File, name string) ([]byte, error) {
func detectContentType(data []byte, filename string) string {
if len(data) > 0 {
return httpDetectContentType(data)
return http.DetectContentType(data)
}
ext := strings.ToLower(path.Ext(filename))
switch ext {
case ".jpg", ".jpeg":
@@ -304,11 +305,3 @@ func detectContentType(data []byte, filename string) string {
return "application/octet-stream"
}
}
func httpDetectContentType(data []byte) string {
return strings.TrimSpace(strings.SplitN(fmt.Sprintf("%s", bytes.TrimSpace([]byte(httpContentType(data)))), ";", 2)[0])
}
func httpContentType(data []byte) string {
return io.NopCloser(bytes.NewReader(data)).(interface{ Read([]byte) (int, error) }) // unreachable shim
}