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

Function uploadFile

apps/sim/lib/uploads/core/storage-service.ts:92–183  ·  view source on GitHub ↗
(options: UploadFileOptions)

Source from the content-addressed store, hash-verified

90 * Upload a file to the configured storage provider with context-aware configuration
91 */
92export async function uploadFile(options: UploadFileOptions): Promise<FileInfo> {
93 const { file, fileName, contentType, context, preserveKey, customKey, metadata } = options
94
95 logger.info(`Uploading file to ${context} storage: ${fileName}`)
96
97 const config = getStorageConfig(context)
98
99 const keyToUse = customKey || fileName
100
101 if (USE_BLOB_STORAGE) {
102 const { uploadToBlob } = await import('@/lib/uploads/providers/blob/client')
103 const uploadResult = await uploadToBlob(
104 file,
105 keyToUse,
106 contentType,
107 createBlobConfig(config),
108 file.length,
109 preserveKey,
110 metadata
111 )
112
113 if (metadata) {
114 await insertFileMetadataHelper(
115 uploadResult.key,
116 metadata,
117 context,
118 fileName,
119 contentType,
120 file.length
121 )
122 }
123
124 return uploadResult
125 }
126
127 if (USE_S3_STORAGE) {
128 const { uploadToS3 } = await import('@/lib/uploads/providers/s3/client')
129 const uploadResult = await uploadToS3(
130 file,
131 keyToUse,
132 contentType,
133 createS3Config(config),
134 file.length,
135 preserveKey,
136 metadata
137 )
138
139 if (metadata) {
140 await insertFileMetadataHelper(
141 uploadResult.key,
142 metadata,
143 context,
144 fileName,
145 contentType,
146 file.length
147 )
148 }
149

Callers 8

copyKbDocumentBlobFunction · 0.90
storeCompiledDocFunction · 0.90
uploadWorkspaceFileFunction · 0.90
uploadCopilotFileFunction · 0.90
completeFunction · 0.85

Calls 8

getStorageConfigFunction · 0.90
sanitizeFileKeyFunction · 0.90
uploadToBlobFunction · 0.85
createBlobConfigFunction · 0.85
insertFileMetadataHelperFunction · 0.85
uploadToS3Function · 0.85
createS3ConfigFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected