Spaces:
Runtime error
Runtime error
| import { S3Client } from "@aws-sdk/client-s3"; | |
| function required(name: string): string { | |
| const value = process.env[name]; | |
| if (!value) { | |
| throw new Error(`Missing environment variable: ${name}`); | |
| } | |
| return value; | |
| } | |
| export const R2_BUCKET_NAME = required("R2_BUCKET_NAME"); | |
| export const r2 = new S3Client({ | |
| region: "auto", | |
| endpoint: `https://${required("R2_ACCOUNT_ID")}.r2.cloudflarestorage.com`, | |
| credentials: { | |
| accessKeyId: required("R2_ACCESS_KEY_ID"), | |
| secretAccessKey: required("R2_SECRET_ACCESS_KEY"), | |
| }, | |
| }); |