fix: mime error in document streams (#1523)

Update document.py

edit got file mime error

Signed-off-by: DavidLee <yongsheng_li@foxmail.com>
This commit is contained in:
DavidLee 2025-05-06 15:30:46 +08:00 committed by GitHub
parent 7c705739f9
commit f1658edbad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -303,6 +303,14 @@ class _DocumentConversionInput(BaseModel):
else ""
)
mime = _DocumentConversionInput._mime_from_extension(ext)
if mime is not None and mime.lower() == "application/zip":
objname = obj.name.lower()
if objname.endswith(".xlsx"):
mime = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
elif objname.endswith(".docx"):
mime = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
elif objname.endswith(".pptx"):
mime = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
mime = mime or _DocumentConversionInput._detect_html_xhtml(content)
mime = mime or _DocumentConversionInput._detect_csv(content)