Merge pull request 'upd: test api' (#54) from amalia/01-des-25 into main
Reviewed-on: http://wibugit.wibudev.com/wibu/jenna-mcp/pulls/54
This commit is contained in:
@@ -8,7 +8,7 @@ import { generateNoPengaduan } from "../lib/no-pengaduan"
|
||||
import { isValidPhone, normalizePhoneNumber } from "../lib/normalizePhone"
|
||||
import { prisma } from "../lib/prisma"
|
||||
import { renameFile } from "../lib/rename-file"
|
||||
import { catFile, defaultConfigSF, removeFile, uploadFile, uploadFileBase64 } from "../lib/seafile"
|
||||
import { catFile, defaultConfigSF, removeFile, uploadFile, uploadFileToFolder } from "../lib/seafile"
|
||||
|
||||
const PengaduanRoute = new Elysia({
|
||||
prefix: "pengaduan",
|
||||
@@ -538,7 +538,7 @@ const PengaduanRoute = new Elysia({
|
||||
|
||||
return {
|
||||
success: true,
|
||||
file : JSON.stringify(file),
|
||||
file: JSON.stringify(file),
|
||||
fileInfo: {
|
||||
name: file.name || 'kosong',
|
||||
size: file.size || 0,
|
||||
@@ -562,9 +562,10 @@ const PengaduanRoute = new Elysia({
|
||||
},
|
||||
})
|
||||
.post("/upload-base64", async ({ body }) => {
|
||||
const { data, mimetype } = body;
|
||||
const { data, mimetype, kategori } = body;
|
||||
const ext = mimeToExtension(mimetype)
|
||||
const name = `${uuidv4()}.${ext}`
|
||||
const kategoriFix = kategori === 'pengaduan' ? 'pengaduan' : 'syarat-dokumen';
|
||||
|
||||
// Validasi file
|
||||
if (!data) {
|
||||
@@ -576,7 +577,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 }, kategoriFix);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -585,12 +587,14 @@ const PengaduanRoute = new Elysia({
|
||||
name,
|
||||
mimetype,
|
||||
ext,
|
||||
kategori,
|
||||
}
|
||||
};
|
||||
}, {
|
||||
body: t.Object({
|
||||
data: t.String(),
|
||||
mimetype: t.String()
|
||||
mimetype: t.String(),
|
||||
kategori: t.String()
|
||||
}),
|
||||
detail: {
|
||||
summary: "Upload File (Base64)",
|
||||
|
||||
Reference in New Issue
Block a user