fix: image not on delete data

This commit is contained in:
Methapon2001 2024-04-04 11:02:01 +07:00
parent 48c9fe1cfd
commit 88f84256cf
2 changed files with 7 additions and 0 deletions

View file

@ -161,5 +161,8 @@ export class BranchContactController extends Controller {
if (result.count <= 0) { if (result.count <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found"); throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found");
} }
await minio.removeObject(MINIO_BUCKET, imageLocation(contactId), {
forceDelete: true,
});
} }
} }

View file

@ -325,6 +325,10 @@ export class UserController extends Controller {
throw new HttpError(HttpStatus.FORBIDDEN, "User is in used.", "data_in_used"); throw new HttpError(HttpStatus.FORBIDDEN, "User is in used.", "data_in_used");
} }
await minio.removeObject(MINIO_BUCKET, imageLocation(userId), {
forceDelete: true,
});
return await prisma.user.delete({ return await prisma.user.delete({
include: { include: {
province: true, province: true,