Skip to content

Commit

Permalink
[FIX] Fixing regression for remote storage file view (#1063)
Browse files Browse the repository at this point in the history
Fixing regression for remote storage file view

Co-authored-by: Gayathri <[email protected]>
  • Loading branch information
harini-venkataraman and gaya3-zipstack authored Jan 13, 2025
1 parent 06fb3b7 commit 078bff4
Showing 1 changed file with 4 additions and 4 deletions.
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}

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

0 comments on commit 078bff4

Please sign in to comment.