( key: string, uploadId: string, partNumber: number, body: Buffer, customConfig?: S3Config )
| 378 | * is for browser uploads; this is the server-side streaming path. |
| 379 | */ |
| 380 | export async function uploadS3Part( |
| 381 | key: string, |
| 382 | uploadId: string, |
| 383 | partNumber: number, |
| 384 | body: Buffer, |
| 385 | customConfig?: S3Config |
| 386 | ): Promise<S3MultipartPart> { |
| 387 | const config = customConfig || { bucket: S3_CONFIG.bucket, region: S3_CONFIG.region } |
| 388 | const response = await getS3Client().send( |
| 389 | new UploadPartCommand({ |
| 390 | Bucket: config.bucket, |
| 391 | Key: key, |
| 392 | PartNumber: partNumber, |
| 393 | UploadId: uploadId, |
| 394 | Body: body, |
| 395 | }) |
| 396 | ) |
| 397 | if (!response.ETag) { |
| 398 | throw new Error(`S3 UploadPart returned no ETag for part ${partNumber} of ${key}`) |
| 399 | } |
| 400 | return { PartNumber: partNumber, ETag: response.ETag } |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Generate presigned URLs for uploading parts to S3 |
no test coverage detected