feat: upload resource

This commit is contained in:
tao.chen
2026-08-13 19:09:13 +08:00
parent 912c0ed22d
commit f5cb22e8cd
+15
View File
@@ -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,
}