|
|
|
@@ -366,14 +366,7 @@ class FileService(CommonService): |
|
|
|
"size": len(blob), |
|
|
|
"thumbnail": thumbnail(filename, blob) |
|
|
|
} |
|
|
|
if doc["type"] == FileType.VISUAL: |
|
|
|
doc["parser_id"] = ParserType.PICTURE.value |
|
|
|
if doc["type"] == FileType.AURAL: |
|
|
|
doc["parser_id"] = ParserType.AUDIO.value |
|
|
|
if re.search(r"\.(ppt|pptx|pages)$", filename): |
|
|
|
doc["parser_id"] = ParserType.PRESENTATION.value |
|
|
|
if re.search(r"\.(eml)$", filename): |
|
|
|
doc["parser_id"] = ParserType.EMAIL.value |
|
|
|
self.set_constant_parser(doc, filename) |
|
|
|
DocumentService.insert(doc) |
|
|
|
|
|
|
|
FileService.add_file_from_kb(doc, kb_folder["id"], kb.tenant_id) |
|
|
|
@@ -381,4 +374,15 @@ class FileService(CommonService): |
|
|
|
except Exception as e: |
|
|
|
err.append(file.filename + ": " + str(e)) |
|
|
|
|
|
|
|
return err, files |
|
|
|
return err, files |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def set_constant_parser(doc, filename): |
|
|
|
if doc["type"] == FileType.VISUAL: |
|
|
|
doc["parser_id"] = ParserType.PICTURE.value |
|
|
|
if doc["type"] == FileType.AURAL: |
|
|
|
doc["parser_id"] = ParserType.AUDIO.value |
|
|
|
if re.search(r"\.(ppt|pptx|pages)$", filename): |
|
|
|
doc["parser_id"] = ParserType.PRESENTATION.value |
|
|
|
if re.search(r"\.(eml)$", filename): |
|
|
|
doc["parser_id"] = ParserType.EMAIL.value |