media more or less working

This commit is contained in:
tsmethurst
2021-03-30 16:06:08 +02:00
parent 572149fa0e
commit 362ccf5817
12 changed files with 112 additions and 363 deletions

View File

@ -26,7 +26,6 @@ import (
"image/gif"
"image/jpeg"
"image/png"
"io"
"github.com/buckket/go-blurhash"
"github.com/h2non/filetype"
@ -36,9 +35,9 @@ import (
// parseContentType parses the MIME content type from a file, returning it as a string in the form (eg., "image/jpeg").
// Returns an error if the content type is not something we can process.
func parseContentType(f io.Reader) (string, error) {
func parseContentType(content []byte) (string, error) {
head := make([]byte, 261)
_, err := f.Read(head)
_, err := bytes.NewReader(content).Read(head)
if err != nil {
return "", fmt.Errorf("could not read first magic bytes of file: %s", err)
}