Optimize file handling for DOCX and PPTX processing.
- Removed redundant file content reading. - Directly passed file to BytesIO. - Simplified DOCX content extraction. - Streamlined PPTX slide processing. - Reduced memory usage in file handling.
This commit is contained in:
@@ -1343,8 +1343,7 @@ def create_app(args):
|
||||
from docx import Document
|
||||
from io import BytesIO
|
||||
|
||||
docx_content = await file.read()
|
||||
docx_file = BytesIO(docx_content)
|
||||
docx_file = BytesIO(file)
|
||||
doc = Document(docx_file)
|
||||
content = "\n".join(
|
||||
[paragraph.text for paragraph in doc.paragraphs]
|
||||
@@ -1355,8 +1354,7 @@ def create_app(args):
|
||||
from pptx import Presentation # type: ignore
|
||||
from io import BytesIO
|
||||
|
||||
pptx_content = await file.read()
|
||||
pptx_file = BytesIO(pptx_content)
|
||||
pptx_file = BytesIO(file)
|
||||
prs = Presentation(pptx_file)
|
||||
for slide in prs.slides:
|
||||
for shape in slide.shapes:
|
||||
|
Reference in New Issue
Block a user