Skip to main content

Workspace Operations

Workspaces are shared file systems in Octostar. Your app can read and write files and check what the current user is permitted to do.

Permission Levels

ValueLevelDescription
1ReadUser can view and download files
2WriteUser can read, create, and overwrite files
3AdminFull control, including workspace management

Checking Permissions

from octostar.utils.workspace.permissions import get_permissions

permissions = await asyncio.to_thread(
client.execute,
get_permissions.sync,
workspace_ids # list of workspace UIDs
)
# Returns: {"workspace_uid_1": 2, "workspace_uid_2": 1, ...}

On the frontend, filter to writable workspaces before letting the user save:

const writableWorkspaces = workspaces.filter(ws => ws.permission >= 2)

get_permissions returns a flat dict keyed by workspace UID. If you are displaying workspaces fetched from dtimbr.os_workspace, merge the permission values into those records before sending them to the frontend.

Writing Files to a Workspace

from io import BytesIO
from octostar.utils.workspace import write_file

content_bytes = json.dumps(data).encode("utf-8")

result = await asyncio.to_thread(
client.execute,
write_file.sync,
workspace_id,
"path/to/file.json", # destination path within the workspace
"application/json", # MIME type
BytesIO(content_bytes),
)

Reading Files from a Workspace

from octostar.utils.workspace import read_file

raw: bytes = await asyncio.to_thread(
client.execute,
read_file.sync,
workspace_id,
"path/to/file.json",
)
data = json.loads(raw)

Getting Open Workspaces (Frontend)

DesktopAPI exposes what the user currently has open in Octostar:

const { DesktopAPI } = useOctostarContext()

const openWorkspaces = await DesktopAPI.getOpenWorkspaces()
const activeWorkspace = await DesktopAPI.getActiveWorkspace()

These are useful for defaulting a workspace picker to the context the user is already working in, rather than asking them to select one.