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

Function buildBody

apps/sim/app/api/table/import-csv/route.test.ts:60–72  ·  view source on GitHub ↗
(parts: Part[])

Source from the content-addressed store, hash-verified

58const BOUNDARY = '----testboundaryCSV'
59
60function buildBody(parts: Part[]): Buffer {
61 const segments: Buffer[] = []
62 for (const part of parts) {
63 let header = `--${BOUNDARY}\r\nContent-Disposition: form-data; name="${part.name}"`
64 if ('filename' in part) {
65 header += `; filename="${part.filename}"\r\nContent-Type: ${part.contentType ?? 'text/csv'}`
66 }
67 header += '\r\n\r\n'
68 segments.push(Buffer.from(header, 'utf8'), Buffer.from(part.value, 'utf8'), Buffer.from('\r\n'))
69 }
70 segments.push(Buffer.from(`--${BOUNDARY}--\r\n`, 'utf8'))
71 return Buffer.concat(segments)
72}
73
74function makeRequest(parts: Part[], chunkSize?: number): NextRequest {
75 const body = buildBody(parts)

Callers 1

makeRequestFunction · 0.70

Calls 2

loadExecutionsForRowFunction · 0.90
eqFunction · 0.50

Tested by

no test coverage detected