Skip to content

Commit

Permalink
fix compat issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Nov 13, 2024
1 parent f066801 commit 93ae389
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
from airbyte_cdk.utils import is_cloud_environment
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
from unstructured.file_utils.filetype import (
FILETYPE_TO_MIMETYPE,
STR_TO_FILETYPE,
FileType,
detect_filetype,
)
Expand Down Expand Up @@ -284,7 +282,7 @@ def _read_file_remotely(

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

file_data = {"files": ("filename", file_handle, FILETYPE_TO_MIMETYPE[filetype])}
file_data = {"files": ("filename", file_handle, filetype.mime_type)}

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

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

0 comments on commit 93ae389

Please sign in to comment.