Merge pull request 'upd: api create pengaduan dg image' (#21) from amalia/12-nov-25 into main
Reviewed-on: http://wibugit.wibudev.com/wibu/jenna-mcp/pulls/21
This commit is contained in:
@@ -100,8 +100,8 @@ const PengaduanRoute = new Elysia({
|
||||
|
||||
// --- PENGADUAN ---
|
||||
.post("/create", async ({ body }) => {
|
||||
const { title, detail, location, imageData, imageMime, idCategory, idWarga, phone } = body
|
||||
let imageFix = null
|
||||
const { title, detail, location, imageName, idCategory, idWarga, phone } = body
|
||||
let imageFix = imageName
|
||||
const noPengaduan = await generateNoPengaduan()
|
||||
let idCategoryFix = idCategory
|
||||
let idWargaFix = idWarga
|
||||
@@ -111,11 +111,11 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
if (!imageData && !imageMime) {
|
||||
const ext = mimeToExtension(imageMime)
|
||||
imageFix = `${uuidv4()}.${ext}`
|
||||
await uploadFileToFolder(defaultConfigSF, { name: imageFix, data: imageData }, "pengaduan")
|
||||
}
|
||||
// if (!imageData && !imageMime) {
|
||||
// const ext = mimeToExtension(imageMime)
|
||||
// imageFix = `${uuidv4()}.${ext}`
|
||||
// await uploadFileToFolder(defaultConfigSF, { name: imageFix, data: imageData }, "pengaduan")
|
||||
// }
|
||||
|
||||
if (!category) {
|
||||
const cariCategory = await prisma.categoryPengaduan.findFirst({
|
||||
@@ -195,8 +195,7 @@ const PengaduanRoute = new Elysia({
|
||||
title: t.String({ minLength: 1, error: "title harus diisi" }),
|
||||
detail: t.String({ minLength: 1, error: "detail harus diisi" }),
|
||||
location: t.String({ minLength: 1, error: "location harus diisi" }),
|
||||
imageData: t.String({ optional: true, description: "base64 encoded image data" }),
|
||||
imageMime: t.String({ optional: true, description: "mime type of image" }),
|
||||
imageName: t.String({ optional: true, description: "nama file gambar yg telah diupload" }),
|
||||
idCategory: t.String({ minLength: 1, error: "idCategory harus diisi" }),
|
||||
idWarga: t.String({ minLength: 1, error: "idWarga harus diisi" }),
|
||||
phone: t.String({ minLength: 1, error: "phone harus diisi" }),
|
||||
@@ -458,7 +457,7 @@ const PengaduanRoute = new Elysia({
|
||||
},
|
||||
})
|
||||
.post("/upload-base64", async ({ body }) => {
|
||||
const { data, mimetype } = body;
|
||||
const { data, mimetype, folder } = body;
|
||||
const ext = mimeToExtension(mimetype)
|
||||
const name = `${uuidv4()}.${ext}`
|
||||
|
||||
@@ -472,7 +471,8 @@ const PengaduanRoute = new Elysia({
|
||||
// const base64String = Buffer.from(buffer).toString("base64");
|
||||
|
||||
// (Opsional) jika perlu dikirim ke Seafile sebagai base64
|
||||
const result = await uploadFileBase64(defaultConfigSF, { name: name, data: data });
|
||||
// const result = await uploadFileBase64(defaultConfigSF, { name: name, data: data });
|
||||
const result = await uploadFileToFolder(defaultConfigSF, { name: name, data: data }, folder);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -486,7 +486,11 @@ const PengaduanRoute = new Elysia({
|
||||
}, {
|
||||
body: t.Object({
|
||||
data: t.String(),
|
||||
mimetype: t.String()
|
||||
mimetype: t.String(),
|
||||
folder: t.Enum({
|
||||
pengaduan: "pengaduan",
|
||||
syarat_dokumen: "syarat-dokumen",
|
||||
})
|
||||
}),
|
||||
detail: {
|
||||
summary: "Upload File (Base64)",
|
||||
|
||||
Reference in New Issue
Block a user