From dc15749c221aeeef28af2dc0e73f7a63efb4b9f2 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sun, 17 May 2026 12:36:30 +0330 Subject: [PATCH] parspack uploader --- src/modules/uploader/providers/s3.service.ts | 24 +++++--------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/modules/uploader/providers/s3.service.ts b/src/modules/uploader/providers/s3.service.ts index f7c204d..661d0bf 100644 --- a/src/modules/uploader/providers/s3.service.ts +++ b/src/modules/uploader/providers/s3.service.ts @@ -13,28 +13,23 @@ export class S3Service { private readonly logger = new Logger(S3Service.name); private readonly s3Client: S3Client; private readonly bucketName: string; - private readonly region: string; // Region is often 'us-east-1' or similar for Liara, but depends on your config - private readonly endpointUrl: string; // Renamed 'url' to 'endpointUrl' for clarity + private readonly region: string; + private readonly endpointUrl: string; constructor(private readonly configService: ConfigService) { - // --- Configuration for Liara S3 --- this.bucketName = this.configService.getOrThrow('BUCKET_NAME'); - // Liara S3 usually requires a specific endpoint URL - this.endpointUrl = this.configService.getOrThrow('LIARA_S3_ENDPOINT'); - // The region for Liara S3 is often 'us-east-1' or just a placeholder, - // but we'll keep it configurable for consistency. + this.endpointUrl = this.configService.getOrThrow('PARSPACK_S3_ENDPOINT'); this.region = this.configService.getOrThrow('BUCKET_REGION'); this.s3Client = new S3Client({ - region: this.region, // Use the configured region - endpoint: this.endpointUrl, // This is the crucial change for Liara S3 - forcePathStyle: true, // Often required when using custom S3 endpoints like Liara + region: this.region, + endpoint: this.endpointUrl, + forcePathStyle: true, credentials: { accessKeyId: this.configService.getOrThrow('BUCKET_ACCESS_KEY'), secretAccessKey: this.configService.getOrThrow('BUCKET_SECRET_KEY'), }, }); - // ------------------------------------ } /** @@ -57,9 +52,6 @@ export class S3Service { {} as Record, ) : undefined; - // NOTE: 'ACL: public-read' might not be supported or necessary for Liara S3, - // depending on your bucket configuration on Liara. - // If uploads fail, try removing this line. const command = new PutObjectCommand({ Bucket: this.bucketName, Key: key, @@ -71,8 +63,6 @@ export class S3Service { await this.s3Client.send(command); - // --- URL for Liara S3 --- - // The public URL for Liara S3 files is typically: ${endpoint}/${bucketName}/${key} const url = `${this.endpointUrl}/${this.bucketName}/${key}`; this.logger.log(`File uploaded to S3: ${key}`); @@ -88,8 +78,6 @@ export class S3Service { } } - // --- Other methods remain the same as they use the S3Client which is now configured for Liara --- - /** * Get file stream from S3 */