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:
@@ -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 },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user