Fixing ODT document extraction (#17700)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
904737a0a2
Коммит
a3fe72abc1
@@ -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
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user