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

Function groupUploadableFiles

apps/sim/providers/file-attachments.server.ts:161–173  ·  view source on GitHub ↗

* Groups large files needing a Files API upload by storage key so a file referenced across * multiple messages uploads once; the resulting handle is then applied to every occurrence.

(messages: Message[] | undefined)

Source from the content-addressed store, hash-verified

159 * multiple messages uploads once; the resulting handle is then applied to every occurrence.
160 */
161function groupUploadableFiles(messages: Message[] | undefined): UserFile[][] {
162 const groups = new Map<string, UserFile[]>()
163 for (const message of messages ?? []) {
164 for (const file of message.files ?? []) {
165 if (!file.remoteUrl || file.providerFileId || file.providerFileUri) continue
166 const dedupeKey = file.key || file.remoteUrl
167 const group = groups.get(dedupeKey)
168 if (group) group.push(file)
169 else groups.set(dedupeKey, [file])
170 }
171 }
172 return [...groups.values()]
173}
174
175/**
176 * Reads the file bytes straight from storage via the storage SDK (not by HTTP-fetching the

Callers 1

Calls 3

getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected