Skip to content

Commit

Permalink
✨ Implement support for s3 storage class
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Oct 24, 2024
1 parent 071b7a7 commit 3c55e7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ S3_REGION=region
S3_ACCESS_KEY=access_key_id
S3_SECRET_KEY=secret_access_key
S3_BUCKET_NAME=bucket_name
S3_STORAGE_CLASS=STANDARD

# Migration
S3_BATCH_SIZE=20
6 changes: 5 additions & 1 deletion src/modules/file/saver/s3.saver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export class S3Saver implements Saver{
async saveFile(data: Buffer, sum: string): Promise<void>{
await this.createBucketIfNotExists();
try{
await this.s3Client.putObject(this.bucketName, `${sum.substring(0, 2)}/${sum}.webp`, data);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
await this.s3Client.putObject(this.bucketName, `${sum.substring(0, 2)}/${sum}.webp`, data, {
"x-amz-storage-class": process.env.S3_STORAGE_CLASS
});
}catch (e){
console.log(`Error saving file ${sum}:`);
console.log(e);
Expand Down

0 comments on commit 3c55e7d

Please sign in to comment.