Skip to content

Commit

Permalink
python(bugfix): Support windows mimetypes for csv upload (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsiftstack authored Nov 22, 2024
1 parent a6e7912 commit 3c8c310
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/lib/sift_py/data_import/_csv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_csv_upload_service_upload_validate_mime_type(mocker: MockFixture):
csv_config=csv_config,
)

with pytest.raises(Exception, match="Must be text or csv"):
with pytest.raises(Exception, match="Must be"):
svc = CsvUploadService(rest_config)
svc.upload(
path="some_file.pdf",
Expand Down
7 changes: 5 additions & 2 deletions python/lib/sift_py/data_import/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,11 @@ def _validate_file_type(self, path: Union[str, Path]) -> Optional[str]:
if not mimetype:
raise Exception(f"The MIME-type of '{posix_path}' could not be computed.")

if mimetype not in ["test/plain", "text/csv"]:
raise Exception(f"{path} is not a valid file type. Must be text or csv.")
valid_types = ["test/plain", "text/csv", "application/vnd.ms-excel"]
if mimetype not in valid_types:
raise Exception(
f"{path} is not a valid file type ({mimetype}). Must be {', '.join(valid_types)}."
)

return content_encoding

Expand Down

0 comments on commit 3c8c310

Please sign in to comment.