import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { S3 } from 'aws-sdk';

@Injectable()
export class FileUploadService {
  static getS3Config: any;
  constructor(private readonly configService: ConfigService) {}

  public getS3Config(): S3.Types.ClientConfiguration {
    return {
      accessKeyId: this.configService.get<string>('AWS_ACCESS_KEY_ID'),
      secretAccessKey: this.configService.get<string>('AWS_SECRET_ACCESS_KEY'),
      region: this.configService.get<string>('AWS_S3_REGION'),
    };
  }

  public getBucketName(): string {
    return this.configService.get<string>('AWS_S3_BUCKET');
  }
  public getPublicBucketName(): string {
    return this.configService.get<string>('AWS_S3_BUCKET_PUBLIC');
  }

  public getS3EndpointUrl(): string {
    return this.configService.get<string>('AWS_S3_ENDPOINT_URL');
  }
}
