Skip to content

Commit 5f358cb

Browse files
authored
python(fix): Parquet file attachment support (#486)
1 parent 42456ca commit 5f358cb

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

python/lib/sift_client/_internal/low_level_wrappers/upload.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import logging
5+
import mimetypes
56
from pathlib import Path
67
from typing import TYPE_CHECKING, Any
78

@@ -16,6 +17,10 @@
1617
# Configure logging
1718
logger = logging.getLogger(__name__)
1819

20+
# Parquet MIME types are not included in mimetypes by default
21+
mimetypes.add_type("application/vnd.apache.parquet", ".pqt")
22+
mimetypes.add_type("application/vnd.apache.parquet", ".parquet")
23+
1924

2025
class UploadLowLevelClient(LowLevelClientBase, WithRestClient):
2126
"""Low-level client for file upload operations.
@@ -182,7 +187,6 @@ def _mime_and_content_type_from_path(path: Path) -> tuple[str, str | None, str |
182187
Returns:
183188
A tuple of (file_name, mime_type, content_encoding).
184189
"""
185-
import mimetypes
186190

187191
file_name = path.name
188192
mime, encoding = mimetypes.guess_type(path)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Tests for UploadLowLevelClient functionality."""
2+
3+
from pathlib import Path
4+
5+
from sift_client._internal.low_level_wrappers.upload import UploadLowLevelClient
6+
7+
8+
class TestUploadLowLevelClient:
9+
class TestMimeAndContentTypeFromPath:
10+
def test_parquet_file_extension(self):
11+
_, mime, _ = UploadLowLevelClient._mime_and_content_type_from_path(Path("data.parquet"))
12+
assert mime == "application/vnd.apache.parquet"
13+
14+
def test_pqt_file_extension(self):
15+
_, mime, _ = UploadLowLevelClient._mime_and_content_type_from_path(Path("data.pqt"))
16+
assert mime == "application/vnd.apache.parquet"

0 commit comments

Comments
 (0)