Skip to content

Commit 078bff4

Browse files
[FIX] Fixing regression for remote storage file view (#1063)
Fixing regression for remote storage file view Co-authored-by: Gayathri <[email protected]>
1 parent 06fb3b7 commit 078bff4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

backend/utils/file_storage/helpers/prompt_studio_file_helper.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import os
44
from pathlib import Path
5-
from typing import Any, Union
5+
from typing import Any
66

77
from file_management.file_management_helper import FileManagerHelper
88
from unstract.sdk.file_storage import FileStorage
@@ -77,7 +77,7 @@ def upload_for_ide(
7777
@staticmethod
7878
def fetch_file_contents(
7979
org_id: str, user_id: str, tool_id: str, file_name: str
80-
) -> Union[bytes, str]:
80+
) -> dict[str, Any]:
8181
"""Method to fetch file contents from the remote location.
8282
The path is constructed in runtime based on the args"""
8383
fs_instance = EnvHelper.get_storage(
@@ -125,7 +125,7 @@ def fetch_file_contents(
125125
encoding="utf-8",
126126
)
127127
encoded_string = base64.b64encode(bytes(text_content_bytes))
128-
return encoded_string
128+
return {"data": encoded_string, "mime_type": file_content_type}
129129

130130
elif file_content_type == "text/plain":
131131
text_content_string: str = fs_instance.read(
@@ -134,7 +134,7 @@ def fetch_file_contents(
134134
legacy_storage_path=legacy_file_path,
135135
encoding="utf-8",
136136
)
137-
return text_content_string
137+
return {"data": text_content_string, "mime_type": file_content_type}
138138
else:
139139
raise ValueError(f"Unsupported file type: {file_content_type}")
140140

0 commit comments

Comments
 (0)