Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fixing regression for remote storage file view #1063

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os
from pathlib import Path
from typing import Any, Union
from typing import Any

from file_management.file_management_helper import FileManagerHelper
from unstract.sdk.file_storage import FileStorage
Expand Down Expand Up @@ -77,7 +77,7 @@ def upload_for_ide(
@staticmethod
def fetch_file_contents(
org_id: str, user_id: str, tool_id: str, file_name: str
) -> Union[bytes, str]:
) -> dict[str, Any]:
"""Method to fetch file contents from the remote location.
The path is constructed in runtime based on the args"""
fs_instance = EnvHelper.get_storage(
Expand Down Expand Up @@ -125,7 +125,7 @@ def fetch_file_contents(
encoding="utf-8",
)
encoded_string = base64.b64encode(bytes(text_content_bytes))
return encoded_string
return {"data": encoded_string, "mime_type": file_content_type}
gaya3-zipstack marked this conversation as resolved.
Show resolved Hide resolved

elif file_content_type == "text/plain":
text_content_string: str = fs_instance.read(
Expand All @@ -134,7 +134,7 @@ def fetch_file_contents(
legacy_storage_path=legacy_file_path,
encoding="utf-8",
)
return text_content_string
return {"data": text_content_string, "mime_type": file_content_type}
else:
raise ValueError(f"Unsupported file type: {file_content_type}")

Expand Down
Loading