upload base64 fix
This commit is contained in:
@@ -5,6 +5,8 @@ import { generateNoPengaduan } from "../lib/no-pengaduan"
|
||||
import { normalizePhoneNumber } from "../lib/normalizePhone"
|
||||
import { prisma } from "../lib/prisma"
|
||||
import { defaultConfigSF, uploadFile, uploadFileBase64 } from "../lib/seafile"
|
||||
import { mimeToExtension } from "../lib/mimetypeToExtension"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
|
||||
const PengaduanRoute = new Elysia({
|
||||
prefix: "pengaduan",
|
||||
@@ -463,7 +465,9 @@ const PengaduanRoute = new Elysia({
|
||||
},
|
||||
})
|
||||
.post("/upload-base64", async ({ body }) => {
|
||||
const { data } = body;
|
||||
const { data, mimetype } = body;
|
||||
const ext = mimeToExtension(mimetype)
|
||||
const name = `${uuidv4()}.${ext}`
|
||||
|
||||
// Validasi file
|
||||
if (!data) {
|
||||
@@ -475,7 +479,7 @@ 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: 'contoh', data: data });
|
||||
const result = await uploadFileBase64(defaultConfigSF, { name: name, data: data});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -487,7 +491,8 @@ const PengaduanRoute = new Elysia({
|
||||
};
|
||||
}, {
|
||||
body: t.Object({
|
||||
data: t.String()
|
||||
data: t.String(),
|
||||
mimetype: t.String()
|
||||
}),
|
||||
detail: {
|
||||
summary: "Upload File (Base64)",
|
||||
|
||||
Reference in New Issue
Block a user