Skip to content

Commit 93ae389

Browse files
committed
fix compat issues
1 parent f066801 commit 93ae389

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

airbyte_cdk/sources/file_based/file_types/unstructured_parser.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
from airbyte_cdk.utils import is_cloud_environment
3030
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
3131
from unstructured.file_utils.filetype import (
32-
FILETYPE_TO_MIMETYPE,
33-
STR_TO_FILETYPE,
3432
FileType,
3533
detect_filetype,
3634
)
@@ -284,7 +282,7 @@ def _read_file_remotely(
284282

285283
data = self._params_to_dict(format.parameters, strategy)
286284

287-
file_data = {"files": ("filename", file_handle, FILETYPE_TO_MIMETYPE[filetype])}
285+
file_data = {"files": ("filename", file_handle, filetype.mime_type)}
288286

289287
response = requests.post(
290288
f"{format.api_url}/general/v0/general", headers=headers, data=data, files=file_data
@@ -350,8 +348,8 @@ def _get_filetype(self, file: IOBase, remote_file: RemoteFile) -> Optional[FileT
350348
2. Use the file name if available
351349
3. Use the file content
352350
"""
353-
if remote_file.mime_type and remote_file.mime_type in STR_TO_FILETYPE:
354-
return STR_TO_FILETYPE[remote_file.mime_type]
351+
if remote_file.mime_type:
352+
return FileType.from_mime_type(remote_file.mime_type)
355353

356354
# set name to none, otherwise unstructured will try to get the modified date from the local file system
357355
if hasattr(file, "name"):

0 commit comments

Comments
 (0)