MCPcopy
hub / github.com/simstudioai/sim / inferContextFromKey

Function inferContextFromKey

apps/sim/lib/uploads/utils/file-utils.ts:579–597  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

577 * `knowledge-base` context.
578 */
579export function inferContextFromKey(key: string): StorageContext {
580 if (!key) {
581 throw new Error('Cannot infer context from empty key')
582 }
583
584 if (key.startsWith('kb/') || key.startsWith('knowledge-base/')) return 'knowledge-base'
585 if (key.startsWith('chat/')) return 'chat'
586 if (key.startsWith('copilot/')) return 'copilot'
587 if (key.startsWith('execution/')) return 'execution'
588 if (key.startsWith('workspace/')) return 'workspace'
589 if (key.startsWith('profile-pictures/')) return 'profile-pictures'
590 if (key.startsWith('og-images/')) return 'og-images'
591 if (key.startsWith('workspace-logos/')) return 'workspace-logos'
592 if (key.startsWith('logs/')) return 'logs'
593
594 throw new Error(
595 `File key must start with a context prefix (kb/, knowledge-base/, chat/, copilot/, execution/, workspace/, profile-pictures/, og-images/, workspace-logos/, or logs/). Got: ${key}`
596 )
597}
598
599/**
600 * Extract storage key and context from an internal file URL

Callers 15

resolveFilePathFunction · 0.90
resolveFileInputToUrlFunction · 0.90
downloadFileFromUrlFunction · 0.90
resolveInternalFileUrlFunction · 0.90
downloadFileFromStorageFunction · 0.90
file-utils.test.tsFile · 0.90
resolveFilePathFromInputFunction · 0.90
verifyFileAccessFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected