upd: coba upload file
Deskripsi: - seafile upload - coba api upload file api No Issues
This commit is contained in:
@@ -158,7 +158,6 @@ export async function uploadFile(config: Config, file: File): Promise<string> {
|
||||
});
|
||||
|
||||
const text = await res.text();
|
||||
console.log(text);
|
||||
|
||||
if (!res.ok) throw new Error(`Upload failed: ${text}`);
|
||||
return `✅ Uploaded ${file.name} successfully`;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { swagger } from "@elysiajs/swagger"
|
||||
import Elysia, { t } from "elysia"
|
||||
import type { StatusPengaduan } from "generated/prisma"
|
||||
import { generateNoPengaduan } from "../lib/no-pengaduan"
|
||||
import { prisma } from "../lib/prisma"
|
||||
import { defaultConfigSF, testConnection, uploadFile } from "../lib/seafile"
|
||||
import { normalizePhoneNumber } from "../lib/normalizePhone"
|
||||
import { prisma } from "../lib/prisma"
|
||||
import { defaultConfigSF, uploadFile } from "../lib/seafile"
|
||||
|
||||
const PengaduanRoute = new Elysia({
|
||||
prefix: "pengaduan",
|
||||
@@ -432,7 +431,6 @@ const PengaduanRoute = new Elysia({
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.use(swagger())
|
||||
.post("/upload",
|
||||
async ({ body }) => {
|
||||
const { file } = body;
|
||||
@@ -442,16 +440,10 @@ const PengaduanRoute = new Elysia({
|
||||
return { success: false, message: "File tidak ditemukan" };
|
||||
}
|
||||
|
||||
// Contoh: cek koneksi ke Seafile
|
||||
const coba = await testConnection(defaultConfigSF);
|
||||
console.log("Seafile Connection:", coba);
|
||||
|
||||
// Upload ke Seafile (pastikan uploadFile menerima Blob atau ArrayBuffer)
|
||||
// const buffer = await file.arrayBuffer();
|
||||
const result = await uploadFile(defaultConfigSF, file);
|
||||
|
||||
console.log("Upload result:", result);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Upload berhasil",
|
||||
|
||||
Reference in New Issue
Block a user