diff --git a/app/(content)/upload/page.tsx b/app/(content)/upload/page.tsx
new file mode 100644
index 0000000..7882fcc
--- /dev/null
+++ b/app/(content)/upload/page.tsx
@@ -0,0 +1,30 @@
+import prisma from "@/lib/prisma";
+
+export default async function UploadTest() {
+ const list = await prisma.file.findMany();
+
+ return (
+
+ {list.map((e) => (
+
+ {e.name}
+ {e.id}
+
+ ))}
+
+
+
+ );
+}
diff --git a/app/(home)/layout.tsx b/app/(home)/layout.tsx
index 493eeca..dbf272e 100644
--- a/app/(home)/layout.tsx
+++ b/app/(home)/layout.tsx
@@ -1,7 +1,6 @@
import { Footer } from "@/components/Footer";
import { Nav } from "@/components/Nav";
import { SITE_META } from "@/constants";
-import { getAllCategories } from "@/lib/categories";
import { Categories } from "../../components/Categories";
export default async function MainLayout({
@@ -11,7 +10,6 @@ export default async function MainLayout({
children: JSX.Element;
params: any;
}) {
- const categories = await getAllCategories();
return (
<>
diff --git a/app/api/files/[id]/route.ts b/app/api/files/[id]/route.ts
new file mode 100644
index 0000000..ff0d511
--- /dev/null
+++ b/app/api/files/[id]/route.ts
@@ -0,0 +1,27 @@
+import prisma from "@/lib/prisma";
+
+export const revalidate = 60 * 60;
+
+export async function GET(
+ request: Request,
+ { params }: { params: { id: string } }
+) {
+ try {
+ const file = await prisma.file.findFirst({
+ where: {
+ name: params.id,
+ },
+ });
+
+ return new Response(file?.data, {
+ // headers: {
+ // "Content-Type": "image/jpeg",
+ // },
+ status: 200,
+ });
+ } catch (error) {
+ return new Response(`error: ${error.message}`, {
+ status: 400,
+ });
+ }
+}
diff --git a/app/api/upload/route.ts b/app/api/upload/route.ts
new file mode 100644
index 0000000..307d011
--- /dev/null
+++ b/app/api/upload/route.ts
@@ -0,0 +1,30 @@
+import prisma from "@/lib/prisma";
+
+export async function POST(request: Request) {
+ try {
+ const text = (await request.formData()).get("file");
+ if (text instanceof File) {
+ console.log(text.name);
+
+ const file = await prisma.file.create({
+ data: {
+ name: text.name,
+ data: Buffer.from(await text.arrayBuffer()),
+ mimeType: "",
+ },
+ });
+ console.log(file);
+ }
+
+ console.log(text instanceof File);
+ // Process the webhook payload
+ } catch (error) {
+ return new Response(`Webhook error: ${error.message}`, {
+ status: 400,
+ });
+ }
+
+ return new Response("Success!", {
+ status: 200,
+ });
+}
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 7c3314c..64db1b9 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -577,3 +577,10 @@ model settings {
key String @id
value String
}
+
+model File {
+ id Int @id @default(autoincrement())
+ name String
+ data Bytes
+ mimeType String
+}