mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-09-12 13:49:13 -04:00
The Tika preview extractor does a network call; it was using context.Background(). Pass the request context from the gRPC handler through Convert so the unpack call respects cancellation and deadlines. Non-I/O decoders ignore the context.
24 lines
516 B
Go
24 lines
516 B
Go
//go:build !enable_vips
|
|
|
|
package preprocessor
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/kovidgoyal/imaging"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// ImageDecoder is a converter for the image file
|
|
type ImageDecoder struct{}
|
|
|
|
// Convert reads the image file and returns the thumbnail image
|
|
func (i ImageDecoder) Convert(_ context.Context, r io.Reader) (any, error) {
|
|
img, err := imaging.Decode(r, imaging.AutoOrientation(true))
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, `could not decode the image`)
|
|
}
|
|
return img, nil
|
|
}
|