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

Function handleUploadFinalize

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

Source from the content-addressed store, hash-verified

181}
182
183async function handleUploadFinalize(
184 req: http.IncomingMessage,
185 res: http.ServerResponse,
186 authorize: AuxiliaryHttpAuthorizer,
187): Promise<void> {
188 try {
189 const auth = await authorize({
190 req,
191 res,
192 daemonRequest: {
193 command: 'upload',
194 positionals: ['finalize'],
195 },
196 });
197 if (!auth) return;
198
199 const body = await readRestJsonBody(req, 64 * 1024);
200 const finalize = readUploadFinalizeBody(body);
201 sendUploadedArtifactResponse(
202 res,
203 await finalizeResumableUpload(finalize.uploadId, auth.tenantId),
204 auth.tenantId,
205 );
206 } catch (error) {
207 sendRestJsonError(res, normalizeError(error));
208 }
209}
210
211function sendJson(res: http.ServerResponse, body: Record<string, unknown>): void {
212 res.statusCode = 200;

Callers 1

handleUploadHttpRouteFunction · 0.85

Calls 6

finalizeResumableUploadFunction · 0.90
sendRestJsonErrorFunction · 0.90
normalizeErrorFunction · 0.90
readRestJsonBodyFunction · 0.85
readUploadFinalizeBodyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…