Skip to content

Commit

Permalink
fix multi extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianliechti committed Oct 7, 2024
1 parent 3172ebb commit a0fec4b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pkg/extractor/multi/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ func (e *Extractor) Extract(ctx context.Context, input extractor.File, options *
options = new(extractor.ExtractOptions)
}

data, err := io.ReadAll(input.Content)
var content []byte

if err != nil {
return nil, err
if input.Content != nil {
data, err := io.ReadAll(input.Content)

if err != nil {
return nil, err
}

content = data
}

for _, p := range e.providers {
if input.Content != nil {
input.Content = bytes.NewReader(data)
file := extractor.File{
URL: input.URL,
}

if content != nil {
file.Content = bytes.NewReader(content)
}

result, err := p.Extract(ctx, input, options)
result, err := p.Extract(ctx, file, options)

if err != nil {
if errors.Is(err, extractor.ErrUnsupported) {
Expand Down

0 comments on commit a0fec4b

Please sign in to comment.