feat: proxy GetObject from Telegram CDN for real S3 client compatibility

- Add proxyS3Get config (PROXY_S3_GET env, default true) to env.ts
- Proxy handleGetObject and handleGetMultipartObject: fetch from Telegram
  CDN and return 200 with streaming body instead of 302 redirect
- Real S3 clients (AWS SDK v3) expect 200+body on GetObject, not redirect
- Legacy 302 redirect path preserved when proxyS3Get=false
- Updated production-e2e: GetObject asserts 200 with body content
- Updated s3-sdk.test.ts: GetObject asserts 200 with body (removed try/catch)
- Cleaned up unused multipart imports in s3-sdk.test.ts

All 49 tests pass (29 production-e2e + 20 s3-sdk).
This commit is contained in:
asepharyana
2026-07-07 02:54:51 +07:00
parent f88ac1a124
commit 06f93e30f6
4 changed files with 94 additions and 32 deletions
+2
View File
@@ -19,6 +19,7 @@ interface AppConfig {
s3AccessKey: string;
s3SecretKey: string;
s3DefaultRegion: string;
proxyS3Get: boolean;
}
const requiredEnv = {
@@ -78,6 +79,7 @@ export const config: AppConfig = {
s3AccessKey: process.env.S3_ACCESS_KEY || 'teleuploader-admin',
s3SecretKey: process.env.S3_SECRET_KEY || '',
s3DefaultRegion: process.env.S3_DEFAULT_REGION || 'us-east-1',
proxyS3Get: process.env.PROXY_S3_GET !== 'false',
};
logger.info('Environment variables loaded', {