feat: add file upload for materials (PDF/DOCX) with ingestion pipeline
This commit is contained in:
20
internal/ingestion/parse_docx.go
Normal file
20
internal/ingestion/parse_docx.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package ingestion
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/nguyenthenguyen/docx"
|
||||
)
|
||||
|
||||
func ParseDOCX(path string) (string, error) {
|
||||
reader, err := docx.ReadDocxFile(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
doc := reader.Editable()
|
||||
text := doc.GetContent()
|
||||
|
||||
return strings.TrimSpace(text), nil
|
||||
}
|
||||
Reference in New Issue
Block a user