Fix cover content type detection build error
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user