(fileSize: number, chunkSize: number)
| 12 | const encoder = new TextEncoder() |
| 13 | |
| 14 | const filePayload = (fileSize: number, chunkSize: number): Array<Uint8Array> => { |
| 15 | const head = encoder.encode( |
| 16 | `--${boundary}\r\ncontent-disposition: form-data; name="file"; filename="file.bin"\r\ncontent-type: application/octet-stream\r\n\r\n` |
| 17 | ) |
| 18 | const body = new Uint8Array(fileSize) |
| 19 | for (let i = 0; i < fileSize; i++) { |
| 20 | body[i] = i % 251 |
| 21 | } |
| 22 | const tail = encoder.encode(`\r\n--${boundary}--\r\n`) |
| 23 | const payload = new Uint8Array(head.length + body.length + tail.length) |
| 24 | payload.set(head, 0) |
| 25 | payload.set(body, head.length) |
| 26 | payload.set(tail, head.length + body.length) |
| 27 | const chunks: Array<Uint8Array> = [] |
| 28 | for (let i = 0; i < payload.length; i += chunkSize) { |
| 29 | chunks.push(payload.subarray(i, i + chunkSize)) |
| 30 | } |
| 31 | return chunks |
| 32 | } |
| 33 | |
| 34 | const fieldsPayload = (fieldCount: number): Array<Uint8Array> => { |
| 35 | let out = "" |
no test coverage detected