MCPcopy Index your code
hub / github.com/callstack/agent-device / handleUploadHttpRoute

Function handleUploadHttpRoute

src/daemon/upload-http.ts:58–79  ·  view source on GitHub ↗
(
  route: UploadHttpRoute,
  req: http.IncomingMessage,
  res: http.ServerResponse,
  authorize: AuxiliaryHttpAuthorizer,
  token: string,
)

Source from the content-addressed store, hash-verified

56}
57
58async 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
81function resolveUploadHttpRoute(req: http.IncomingMessage): UploadHttpRoute | null {
82 if (req.method === 'POST' && req.url === '/upload/preflight') return { kind: 'preflight' };

Callers 1

tryHandleUploadHttpRouteFunction · 0.85

Calls 4

handleUploadPreflightFunction · 0.85
handleResumableUploadFunction · 0.85
handleUploadFinalizeFunction · 0.85
handleUploadFunction · 0.70

Tested by

no test coverage detected