(
artifact: PreparedUploadArtifact,
ticket: Extract<UploadPreflightResult, { kind: 'direct-upload' }>,
onProgress: UploadProgressSink | undefined,
)
| 262 | } |
| 263 | |
| 264 | async 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 | |
| 293 | async function finalizeDirectUpload(options: { |
| 294 | normalizedBase: string; |
no test coverage detected