From f5cb22e8cd16ff4e5c1a223289190f4ddaf752fc Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Thu, 13 Aug 2026 19:09:13 +0800 Subject: [PATCH] feat: upload resource --- backend/src/backend/resources.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/backend/resources.py b/backend/src/backend/resources.py index 2f9eb78..c15004d 100644 --- a/backend/src/backend/resources.py +++ b/backend/src/backend/resources.py @@ -40,6 +40,20 @@ def resource_payload( resource: DataResources, storage_object: StorageObjects, ) -> dict[str, Any]: + # The Jupyter-side path: storage_object.object_key is stored as + # "workspace/{ws_id}/{user_id}/{ulid}{ext}" and Jupyter's root_dir is + # "/workspace/{ws_id}", so Jupyter sees the file at + # "{user_id}/{ulid}{ext}". Strip the workspace/{ws_id}/ prefix so the + # frontend can render a copy-pasteable Jupyter path. + workspace_prefix = f"workspace/{resource.workspace_id}/" + if storage_object.object_key and storage_object.object_key.startswith( + workspace_prefix + ): + jupyter_accessible_path = storage_object.object_key[ + len(workspace_prefix) : + ] + else: + jupyter_accessible_path = storage_object.object_key return { "resource_id": resource.resource_id, "workspace_id": resource.workspace_id, @@ -59,6 +73,7 @@ def resource_payload( "content_hash": storage_object.content_hash, "object_status": storage_object.object_status, }, + "jupyter_accessible_path": jupyter_accessible_path, }