MCPcopy Index your code
hub / github.com/simstudioai/sim / extractWorkspaceIdFromKey

Function extractWorkspaceIdFromKey

apps/sim/app/api/files/authorization.ts:104–119  ·  view source on GitHub ↗

* Extract workspace ID from workspace file key pattern * Pattern: {workspaceId}/{timestamp}-{random}-{filename}

(key: string)

Source from the content-addressed store, hash-verified

102 * Pattern: {workspaceId}/{timestamp}-{random}-{filename}
103 */
104function extractWorkspaceIdFromKey(key: string): string | null {
105 const inferredContext = inferContextFromKey(key)
106 if (inferredContext !== 'workspace') {
107 return null
108 }
109
110 // Use the proper parsing utility from workspace context module
111 const parts = key.split('/')
112 const workspaceId = parts[0]
113
114 if (workspaceId && isUuid(workspaceId)) {
115 return workspaceId
116 }
117
118 return null
119}
120
121/**
122 * Verify file access based on file path patterns and metadata

Callers 1

authorizeFileAccessFunction · 0.85

Calls 2

inferContextFromKeyFunction · 0.90
isUuidFunction · 0.90

Tested by

no test coverage detected