make responses OC10 compatible

This commit is contained in:
David Christofas
2021-04-27 22:09:49 +02:00
parent 5d6b801b8c
commit af03099aba
15 changed files with 310 additions and 238 deletions
+21 -1
View File
@@ -6,6 +6,16 @@ import (
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/thumbnails/pkg/thumbnail/storage"
"image"
"strings"
)
var (
SupportedMimeTypes = [...]string{
"image/png",
"image/jpg",
"image/jpeg",
"image/gif",
}
)
// Request bundles information needed to generate a thumbnail for afile
@@ -40,7 +50,8 @@ type SimpleManager struct {
resolutions Resolutions
}
// Generate implements the Get Method of Manager
// Generate creates a thumbnail and stores it.
// The created thumbnail is also being returned.
func (s SimpleManager) Generate(r Request, img image.Image) ([]byte, error) {
match := s.resolutions.ClosestMatch(r.Resolution, img.Bounds())
thumbnail := s.generate(match, img)
@@ -77,3 +88,12 @@ func mapToStorageRequest(r Request) storage.Request {
Types: r.Encoder.Types(),
}
}
func IsMimeTypeSupported(m string) bool {
for _, mt := range SupportedMimeTypes {
if strings.EqualFold(mt, m) {
return true
}
}
return false
}