Files
bigcapital/packages/server/src/services/Attachments/DeleteAttachment.ts
2024-05-24 14:28:21 +02:00

20 lines
500 B
TypeScript

import { DeleteObjectCommand } from '@aws-sdk/client-s3';
import { s3 } from '@/lib/S3/S3';
import { Service } from 'typedi';
@Service()
export class DeleteAttachment {
/**
* Deletes the give file attachment file key.
* @param {number} tenantId
* @param {string} filekey
*/
async delete(tenantId: number, filekey: string): Promise<void> {
const params = {
Bucket: process.env.AWS_BUCKET,
Key: filekey,
};
await s3.send(new DeleteObjectCommand(params));
}
}