( key: string, customConfig?: S3Config )
| 224 | * never resident in memory. |
| 225 | */ |
| 226 | export async function downloadFromS3Stream( |
| 227 | key: string, |
| 228 | customConfig?: S3Config |
| 229 | ): Promise<Readable> { |
| 230 | const config = customConfig || { bucket: S3_CONFIG.bucket, region: S3_CONFIG.region } |
| 231 | const command = new GetObjectCommand({ Bucket: config.bucket, Key: key }) |
| 232 | const response = await getS3Client().send(command) |
| 233 | if (!response.Body) { |
| 234 | throw new Error(`S3 object has no body: ${key}`) |
| 235 | } |
| 236 | return response.Body as Readable |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Check whether an object exists in S3 (and return its size when it does). |
no test coverage detected