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

Function resolveFilePathFromInput

apps/sim/blocks/blocks/file.ts:11–30  ·  view source on GitHub ↗
(fileInput: unknown)

Source from the content-addressed store, hash-verified

9const logger = createLogger('FileBlock')
10
11const resolveFilePathFromInput = (fileInput: unknown): string | null => {
12 if (!fileInput || typeof fileInput !== 'object') {
13 return null
14 }
15
16 const record = fileInput as Record<string, unknown>
17 if (typeof record.path === 'string' && record.path.trim() !== '') {
18 return record.path
19 }
20 if (typeof record.url === 'string' && record.url.trim() !== '') {
21 return record.url
22 }
23 if (typeof record.key === 'string' && record.key.trim() !== '') {
24 const key = record.key.trim()
25 const context = typeof record.context === 'string' ? record.context : inferContextFromKey(key)
26 return `/api/files/serve/${encodeURIComponent(key)}?context=${context}`
27 }
28
29 return null
30}
31
32const resolveFilePathsFromInput = (fileInput: unknown): string[] => {
33 if (!fileInput) {

Callers 1

Calls 1

inferContextFromKeyFunction · 0.90

Tested by

no test coverage detected