( req: http.IncomingMessage, res: http.ServerResponse, authorize: AuxiliaryHttpAuthorizer, token: string, )
| 114 | } |
| 115 | |
| 116 | async function handleUploadPreflight( |
| 117 | req: http.IncomingMessage, |
| 118 | res: http.ServerResponse, |
| 119 | authorize: AuxiliaryHttpAuthorizer, |
| 120 | token: string, |
| 121 | ): Promise<void> { |
| 122 | try { |
| 123 | const auth = await authorize({ |
| 124 | req, |
| 125 | res, |
| 126 | daemonRequest: { |
| 127 | command: 'upload', |
| 128 | positionals: ['preflight'], |
| 129 | }, |
| 130 | }); |
| 131 | if (!auth) return; |
| 132 | |
| 133 | const body = await readRestJsonBody(req, 64 * 1024); |
| 134 | const preflight = readUploadPreflightBody(body); |
| 135 | const upload = beginResumableUpload({ |
| 136 | baseUrl: resolveHttpRequestBaseUrl(req), |
| 137 | tokenHeaders: buildUploadTicketAuthHeaders(token), |
| 138 | ...preflight, |
| 139 | tenantId: auth.tenantId, |
| 140 | }); |
| 141 | |
| 142 | sendJson(res, { ok: true, ...upload }); |
| 143 | } catch (error) { |
| 144 | sendRestJsonError(res, normalizeError(error)); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | async function handleResumableUpload( |
| 149 | uploadId: string, |
no test coverage detected
searching dependent graphs…