fix file type detect bug (#3172)
This commit is contained in:
@@ -428,6 +428,10 @@ async def get_onepassword_token(
|
|||||||
response_model=CreateOnePasswordTokenResponse,
|
response_model=CreateOnePasswordTokenResponse,
|
||||||
summary="Create or update OnePassword service account token",
|
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.",
|
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(
|
@base_router.post(
|
||||||
"/credentials/onepassword/create/",
|
"/credentials/onepassword/create/",
|
||||||
|
|||||||
@@ -2450,12 +2450,14 @@ class FileParserBlock(Block):
|
|||||||
|
|
||||||
def _detect_file_type_from_url(self, file_url: str) -> FileType:
|
def _detect_file_type_from_url(self, file_url: str) -> FileType:
|
||||||
"""Detect file type based on file extension in the URL."""
|
"""Detect file type based on file extension in the URL."""
|
||||||
url_lower = file_url.lower()
|
url_parsed = urlparse(file_url)
|
||||||
if url_lower.endswith((".xlsx", ".xls", ".xlsm")):
|
# 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
|
return FileType.EXCEL
|
||||||
elif url_lower.endswith(".pdf"):
|
elif suffix == ".pdf":
|
||||||
return FileType.PDF
|
return FileType.PDF
|
||||||
elif url_lower.endswith(".tsv"):
|
elif suffix == ".tsv":
|
||||||
return FileType.CSV # TSV files are handled by the CSV parser
|
return FileType.CSV # TSV files are handled by the CSV parser
|
||||||
else:
|
else:
|
||||||
return FileType.CSV # Default to CSV for .csv and any other extensions
|
return FileType.CSV # Default to CSV for .csv and any other extensions
|
||||||
|
|||||||
Reference in New Issue
Block a user