MCPcopy Create free account
hub / github.com/callstack/agent-device / handleUploadPreflight

Function handleUploadPreflight

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

Source from the content-addressed store, hash-verified

114}
115
116async 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
148async function handleResumableUpload(
149 uploadId: string,

Callers 1

handleUploadHttpRouteFunction · 0.85

Calls 8

beginResumableUploadFunction · 0.90
sendRestJsonErrorFunction · 0.90
normalizeErrorFunction · 0.90
readRestJsonBodyFunction · 0.85
readUploadPreflightBodyFunction · 0.85
sendJsonFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…