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

Function processSingleFileToUserFile

apps/sim/lib/uploads/utils/file-utils.ts:753–772  ·  view source on GitHub ↗
(
  file: RawFileInput,
  requestId: string,
  logger: Logger
)

Source from the content-addressed store, hash-verified

751 * @throws Error if file is an array or has no storage key
752 */
753export function processSingleFileToUserFile(
754 file: RawFileInput,
755 requestId: string,
756 logger: Logger
757): UserFile {
758 if (Array.isArray(file)) {
759 const errorMsg = `Expected a single file but received an array with ${file.length} file(s). Use a file input that accepts multiple files, or select a specific file from the array (e.g., {{block.files[0]}}).`
760 logger.error(`[${requestId}] ${errorMsg}`)
761 throw new Error(errorMsg)
762 }
763
764 const userFile = convertToUserFile(file, requestId, logger)
765 if (!userFile) {
766 const errorMsg = `File has no storage key: ${file.name || 'unknown'}`
767 logger.warn(`[${requestId}] ${errorMsg}`)
768 throw new Error(errorMsg)
769 }
770
771 return userFile
772}
773
774/**
775 * Converts raw file objects to UserFile format, accepting single or array input

Callers 14

resolveFileInputToUrlFunction · 0.90
file-utils.test.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 3

convertToUserFileFunction · 0.85
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected