From 078bff4d6f4ee5d5b8b7ffd4913049f3ecccbd44 Mon Sep 17 00:00:00 2001 From: harini-venkataraman <115449948+harini-venkataraman@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:44:22 +0530 Subject: [PATCH] [FIX] Fixing regression for remote storage file view (#1063) Fixing regression for remote storage file view Co-authored-by: Gayathri <142381512+gaya3-zipstack@users.noreply.github.com> --- .../file_storage/helpers/prompt_studio_file_helper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/utils/file_storage/helpers/prompt_studio_file_helper.py b/backend/utils/file_storage/helpers/prompt_studio_file_helper.py index 8b6811069..5bd01c73d 100644 --- a/backend/utils/file_storage/helpers/prompt_studio_file_helper.py +++ b/backend/utils/file_storage/helpers/prompt_studio_file_helper.py @@ -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 @@ -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( @@ -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( @@ -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}")