Files
documenso/packages/lib/universal/upload/delete-file.ts
2025-02-13 14:10:38 +11:00

22 lines
519 B
TypeScript

import { DocumentDataType } from '@prisma/client';
import { match } from 'ts-pattern';
import { deleteS3File } from './server-actions';
export type DeleteFileOptions = {
type: DocumentDataType;
data: string;
};
export const deleteFile = async ({ type, data }: DeleteFileOptions) => {
return await match(type)
.with(DocumentDataType.S3_PATH, async () => deleteFileFromS3(data))
.otherwise(() => {
return;
});
};
const deleteFileFromS3 = async (key: string) => {
await deleteS3File(key);
};