( route: UploadHttpRoute, req: http.IncomingMessage, res: http.ServerResponse, authorize: AuxiliaryHttpAuthorizer, token: string, )
| 56 | } |
| 57 | |
| 58 | async function handleUploadHttpRoute( |
| 59 | route: UploadHttpRoute, |
| 60 | req: http.IncomingMessage, |
| 61 | res: http.ServerResponse, |
| 62 | authorize: AuxiliaryHttpAuthorizer, |
| 63 | token: string, |
| 64 | ): Promise<void> { |
| 65 | switch (route.kind) { |
| 66 | case 'preflight': |
| 67 | await handleUploadPreflight(req, res, authorize, token); |
| 68 | return; |
| 69 | case 'direct': |
| 70 | await handleResumableUpload(route.uploadId, req, res, authorize); |
| 71 | return; |
| 72 | case 'finalize': |
| 73 | await handleUploadFinalize(req, res, authorize); |
| 74 | return; |
| 75 | case 'upload': |
| 76 | await handleUpload(req, res, authorize); |
| 77 | return; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | function resolveUploadHttpRoute(req: http.IncomingMessage): UploadHttpRoute | null { |
| 82 | if (req.method === 'POST' && req.url === '/upload/preflight') return { kind: 'preflight' }; |
no test coverage detected