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

Function uploadDirectArtifact

src/remote/upload-client.ts:264–291  ·  view source on GitHub ↗
(
  artifact: PreparedUploadArtifact,
  ticket: Extract<UploadPreflightResult, { kind: 'direct-upload' }>,
  onProgress: UploadProgressSink | undefined,
)

Source from the content-addressed store, hash-verified

262}
263
264async function uploadDirectArtifact(
265 artifact: PreparedUploadArtifact,
266 ticket: Extract<UploadPreflightResult, { kind: 'direct-upload' }>,
267 onProgress: UploadProgressSink | undefined,
268): Promise<void> {
269 const response = await streamFileToHttpRequest({
270 url: new URL(ticket.url),
271 method: 'PUT',
272 headers: ticket.headers,
273 payloadPath: artifact.payloadPath,
274 timeoutMessage: 'Direct artifact upload timed out',
275 timeoutHint: 'The direct upload ticket did not accept the artifact within the timeout.',
276 errorMessage: 'Failed to upload artifact with direct upload ticket',
277 retryable: true,
278 progress: {
279 stage: 'direct',
280 fileName: artifact.fileName,
281 onProgress,
282 },
283 });
284
285 if (response.statusCode < 200 || response.statusCode >= 300) {
286 throw new AppError('COMMAND_FAILED', 'Direct artifact upload failed', {
287 statusCode: response.statusCode,
288 statusMessage: response.statusMessage,
289 });
290 }
291}
292
293async function finalizeDirectUpload(options: {
294 normalizedBase: string;

Callers 1

uploadOnceFunction · 0.85

Calls 1

streamFileToHttpRequestFunction · 0.90

Tested by

no test coverage detected