ncp 오브젝트 스토리지 설정 - 이미 도커 파일 때문에 ticle 존재
api 키 발급
https://guide.ncloud-docs.com/docs/apigw-apigw-2-5
각자 서브 어카운트 계정에서 계정관리에 들어가서
ACCESS_KEY
, SECRET_KEY
발급
오브젝트 관련 환경변수 알아야함
NCP_OBJECT_STORAGE_REGION=kr-standard
NCP_OBJECT_STORAGE_ENDPOINT=https://kr.object.ncloudstorage.com
NCP_OBJECT_STORAGE_BUCKET='우리버킷이름'
S3 클라이언트 설정
this.s3Client = new S3Client({
region: region,
credentials: {
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
},
endpoint: endpoint,
forcePathStyle: true,
});
s3 오브젝트에 올리는 코드
const bucketName = this.configService.get<string>('NCP_OBJECT_STORAGE_BUCKET');
const endpoint = this.configService.get<string>('NCP_OBJECT_STORAGE_ENDPOINT');
const fileStream = fs.createReadStream(localFilePath);
const params = {
Bucket: bucketName,
Key: remoteFileName,
Body: fileStream,
};
const uploadResponse = await this.s3.send(new PutObjectCommand(params));