(parts: Part[])
| 58 | const BOUNDARY = '----testboundaryCSV' |
| 59 | |
| 60 | function 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 | |
| 74 | function makeRequest(parts: Part[], chunkSize?: number): NextRequest { |
| 75 | const body = buildBody(parts) |
no test coverage detected