()
| 43 | } |
| 44 | |
| 45 | export function getS3Client(): S3Client { |
| 46 | if (_s3Client) return _s3Client |
| 47 | |
| 48 | const { region } = S3_CONFIG |
| 49 | |
| 50 | if (!region) { |
| 51 | throw new Error( |
| 52 | 'AWS region is missing – set AWS_REGION in your environment or disable S3 uploads.' |
| 53 | ) |
| 54 | } |
| 55 | |
| 56 | _s3Client = new S3Client({ |
| 57 | region, |
| 58 | endpoint: S3_CONFIG.endpoint, |
| 59 | forcePathStyle: S3_CONFIG.forcePathStyle, |
| 60 | credentials: getAwsCredentialsFromEnv(), |
| 61 | }) |
| 62 | |
| 63 | return _s3Client |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Upload a file to S3 |
no test coverage detected