fix(storage): migrate domain-specific delete and update handlers to MinIO

- Replaces local filesystem operations (fs.unlink, path.join) with MinIO removeObject in all domain lib handlers
- Updated handlers for: Berita, GalleryFoto, Layanan, Musik, Penghargaan, Potensi, Profile, Inovasi, Keamanan, Kesehatan, LandingPage, and PPID
- bump: version 0.1.19 -> 0.1.20
This commit is contained in:
2026-04-23 17:05:44 +08:00
parent 37940fc7e2
commit b9d43eb723
41 changed files with 97 additions and 191 deletions

View File

@@ -1,8 +1,7 @@
import prisma from "@/lib/prisma";
import { Prisma } from "@prisma/client";
import path from "path";
import fs from "fs/promises";
import { Context } from "elysia";
import minio, { MINIO_BUCKET } from "@/lib/minio";
type FormUpdate = Prisma.PenghargaanGetPayload<{
select: {
@@ -60,8 +59,7 @@ try {
const oldImage = existing.image;
if (oldImage) {
try {
const filePath = path.join(oldImage.path, oldImage.name);
await fs.unlink(filePath);
await minio.removeObject(MINIO_BUCKET, `${oldImage.path}/${oldImage.name}`);
await prisma.fileStorage.delete({
where: { id: oldImage.id },
});