Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[FIX] Remote-storage - Multi-doc upload (#1121)

Gayathri0f0be5d81e71
diff --git a/backend/prompt_studio/prompt_studio_core_v2/views.py b/backend/prompt_studio/prompt_studio_core_v2/views.py
index 4eaa67bdb..c33d6ac95 100644
--- a/backend/prompt_studio/prompt_studio_core_v2/views.py
+++ b/backend/prompt_studio/prompt_studio_core_v2/views.py
@@ -513,7 +513,8 @@ class PromptStudioCoreView(viewsets.ModelViewSet):
org_id=UserSessionUtils.get_organization_id(request),
user_id=custom_tool.created_by.user_id,
tool_id=str(custom_tool.tool_id),
- uploaded_file=file_data,
+ file_name=file_name,
+ file_data=file_data,
)
# Create a record in the db for the file
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 5bd01c73d..86fdfa7ba 100644
--- a/backend/utils/file_storage/helpers/prompt_studio_file_helper.py
+++ b/backend/utils/file_storage/helpers/prompt_studio_file_helper.py
@@ -49,7 +49,7 @@ class PromptStudioFileHelper:
@staticmethod
def upload_for_ide(
- org_id: str, user_id: str, tool_id: str, uploaded_file: Any
+ org_id: str, user_id: str, tool_id: str, file_data: Any, file_name: str
) -> None:
"""Uploads the file to a remote storage
@@ -57,7 +57,8 @@ class PromptStudioFileHelper:
org_id (str): Organization ID
user_id (str): User ID
tool_id (str): ID of the prompt studio tool
- uploaded_file : File to upload to remote
+ file_data (Any) : File data
+ file_name (str) : Name of the file to be uploaded
"""
fs_instance = EnvHelper.get_storage(
storage_type=StorageType.PERMANENT,
@@ -71,8 +72,13 @@ class PromptStudioFileHelper:
tool_id=str(tool_id),
)
)
- file_path = str(Path(file_system_path) / uploaded_file.name)
- fs_instance.write(path=file_path, mode="wb", data=uploaded_file.read())
+
+ file_path = str(Path(file_system_path) / file_name)
+ fs_instance.write(
+ path=file_path,
+ mode="wb",
+ data=file_data if isinstance(file_data, bytes) else file_data.read(),
+ )
@staticmethod
def fetch_file_contents(