Этот коммит содержится в:
Jesús Espino
2021-06-02 09:29:46 +02:00
коммит произвёл GitHub
родитель 904737a0a2
Коммит a3fe72abc1
2 изменённых файлов: 9 добавлений и 16 удалений

Просмотреть файл

@@ -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",

Просмотреть файл

@@ -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
}