linstrom/storage/mediaProvider/preprocessor.go

36 lines
704 B
Go

package mediaprovider
import (
"io"
"strings"
"github.com/gabriel-vasile/mimetype"
)
func Compress(dataReader io.Reader, mimeType *string) (io.Reader, error) {
data, err := io.ReadAll(dataReader)
if err != nil {
return nil, err
}
if mimeType == nil {
*mimeType = mimetype.Detect(data).String()
}
uberType, subType, _ := strings.Cut(*mimeType, "/")
var dataOut []byte
switch uberType {
case "text":
case "application":
case "image":
case "video":
dataOut, err = compressVideo(data, subType)
case "audio":
case "font":
default:
}
return nil, nil
}
func compressVideo(dataIn []byte, subType string) (dataOut []byte, err error) {
// TODO: Implement me
panic("Implement me")
}