diff --git a/src/common/helper/env.validation.ts b/src/common/helper/env.validation.ts index 55c6c34..6b857cf 100644 --- a/src/common/helper/env.validation.ts +++ b/src/common/helper/env.validation.ts @@ -79,16 +79,16 @@ export class EnvironmentVariables { GPT_KEY: string; @IsString() - NCP_ACCESS_KEY_ID: string; + AWS_S3_ACCESS_KEY: string; @IsString() - NCP_SECRET_ACCESS_KEY: string; + AWS_S3_SECRET_KEY: string; @IsString() - NCP_BUCKET_NAME: string; + AWS_S3_REGION: string; @IsString() - NCP_ENDPOINT: string; + AWS_S3_BUCKET_NAME: string; } export function envValidation(config: Record) { diff --git a/src/upload/upload.service.ts b/src/upload/upload.service.ts index f6187c2..d9f4a32 100644 --- a/src/upload/upload.service.ts +++ b/src/upload/upload.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import AWS, { S3 } from 'aws-sdk'; +import { S3 } from 'aws-sdk'; @Injectable() export class UploadService { @@ -9,10 +9,11 @@ export class UploadService { constructor(private readonly configService: ConfigService) { this.awsS3 = new S3({ - endpoint: new AWS.Endpoint(this.configService.get('NCP_ENDPOINT')), - accessKeyId: this.configService.get('NCP_ACCESS_KEY_ID'), - secretAccessKey: this.configService.get('NCP_SECRET_ACCESS_KEY'), - region: 'kr-standard', + region: this.configService.get('AWS_S3_REGION'), + credentials: { + accessKeyId: this.configService.get('AWS_S3_ACCESS_KEY'), + secretAccessKey: this.configService.get('AWS_S3_SECRET_KEY'), + }, }); } @@ -20,7 +21,7 @@ export class UploadService { try { const uploadResult = await this.awsS3 .upload({ - Bucket: this.configService.get('NCP_BUCKET_NAME'), + Bucket: this.configService.get('AWS_S3_BUCKET_NAME'), Key: folder + file.originalname, Body: file.buffer, ContentType: file.mimetype,