From a3fe72abc1ca617ae9e6754c0bd31338517ee9f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Wed, 2 Jun 2021 09:29:46 +0200 Subject: [PATCH] Fixing ODT document extraction (#17700) --- services/docextractor/docextractor_test.go | 8 ++++++++ services/docextractor/documents.go | 17 +---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/services/docextractor/docextractor_test.go b/services/docextractor/docextractor_test.go index 864ebaf2c1..cda8e9fa2d 100644 --- a/services/docextractor/docextractor_test.go +++ b/services/docextractor/docextractor_test.go @@ -105,6 +105,14 @@ func TestExtract(t *testing.T) { []string{}, false, }, + { + "Odt file", + "sample-doc.odt", + ExtractSettings{}, + []string{"simple", "document", "contains"}, + []string{}, + false, + }, { "Pptx file", "sample-doc.pptx", diff --git a/services/docextractor/documents.go b/services/docextractor/documents.go index 91ad5c428b..f67c17fd50 100644 --- a/services/docextractor/documents.go +++ b/services/docextractor/documents.go @@ -5,10 +5,7 @@ package docextractor import ( "errors" - "fmt" "io" - "io/ioutil" - "os" "path" "strings" @@ -41,19 +38,7 @@ func (de *documentExtractor) Extract(filename string, r io.ReadSeeker) (string, return "", errors.New("unknown converter") } - f, err := ioutil.TempFile(os.TempDir(), "docconv") - if err != nil { - return "", fmt.Errorf("error creating temporary file: %v", err) - } - defer f.Close() - defer os.Remove(f.Name()) - - _, err = io.Copy(f, r) - if err != nil { - return "", fmt.Errorf("error copying data into temporary file: %v", err) - } - - text, _, err := converter(f) + text, _, err := converter(r) if err != nil { return "", err }