fix file type detect bug (#3172)

This commit is contained in:
LawyZheng
2025-08-13 11:24:20 +08:00
committed by GitHub
parent 5132501cc6
commit 2a4b26f8e6
2 changed files with 10 additions and 4 deletions

View File

@@ -428,6 +428,10 @@ async def get_onepassword_token(
response_model=CreateOnePasswordTokenResponse,
summary="Create or update OnePassword service account token",
description="Creates or updates a OnePassword service account token for the current organization. Only one valid token is allowed per organization.",
tags=["Auth Tokens"],
openapi_extra={
"x-fern-sdk-method-name": "update_onepassword_token",
},
)
@base_router.post(
"/credentials/onepassword/create/",

View File

@@ -2450,12 +2450,14 @@ class FileParserBlock(Block):
def _detect_file_type_from_url(self, file_url: str) -> FileType:
"""Detect file type based on file extension in the URL."""
url_lower = file_url.lower()
if url_lower.endswith((".xlsx", ".xls", ".xlsm")):
url_parsed = urlparse(file_url)
# TODO: use filetype.guess(file_path) to make the detection more robust
suffix = Path(url_parsed.path).suffix.lower()
if suffix in (".xlsx", ".xls", ".xlsm"):
return FileType.EXCEL
elif url_lower.endswith(".pdf"):
elif suffix == ".pdf":
return FileType.PDF
elif url_lower.endswith(".tsv"):
elif suffix == ".tsv":
return FileType.CSV # TSV files are handled by the CSV parser
else:
return FileType.CSV # Default to CSV for .csv and any other extensions