Skip to content

Commit

Permalink
fix: Fix file suffix checking (#219)
Browse files Browse the repository at this point in the history
Fix file suffix checking
  • Loading branch information
sjrl authored Nov 12, 2024
1 parent 4d32be3 commit 1032337
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions deepset_cloud_sdk/_api/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ async def direct_upload_path(
:param file_path: Path to the file to upload.
:param file_name: Name of the file to upload.
:param meta: Meta information to attach to the file.
:param write_mode: Specifies what to do when a file with the same name already exists in the workspace.
Possible options are:
KEEP - uploads the file with the same name and keeps both files in the workspace.
OVERWRITE - overwrites the file that is in the workspace.
FAIL - fails to upload the file with the same name.
:return: ID of the uploaded file.
"""
if isinstance(file_path, str):
Expand Down Expand Up @@ -210,7 +215,7 @@ async def direct_upload_in_memory(
"""Directly upload files to deepset Cloud.
:param workspace_name: Name of the workspace to use.
:param text: File text to upload.
:param content: File text to upload.
:param file_name: Name of the file to upload.
:param meta: Meta information to attach to the file.
:param write_mode: Specifies what to do when a file with the same name already exists in the workspace.
Expand All @@ -220,7 +225,7 @@ async def direct_upload_in_memory(
FAIL - fails to upload the file with the same name.
:return: ID of the uploaded file.
"""
file_name_suffix = f".{file_name.split('.')[1]}"
file_name_suffix = Path(file_name).suffix
if file_name_suffix not in SUPPORTED_TYPE_SUFFIXES:
raise NotMatchingFileTypeException(
f"File name {file_name} is not a supported file type. Please use one of {'` '.join(SUPPORTED_TYPE_SUFFIXES)} for text uploads."
Expand Down

0 comments on commit 1032337

Please sign in to comment.