BIG MOOOOVE to Object Storage
Deploy / deploy (push) Successful in 2m43s

This commit is contained in:
twotalesanimation
2026-07-16 22:15:58 +02:00
parent 3264abb432
commit 745634f1b6
10 changed files with 594 additions and 17 deletions
+3 -2
View File
@@ -1,7 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { uploadFile } from "@/lib/storage";
import { uploadToHetzner } from "@/lib/storage";
function canManage(role: string) {
return ["ADMIN", "PRODUCER", "SUPERVISOR"].includes(role);
@@ -44,7 +44,8 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: "File too large (max 20 MB)" }, { status: 413 });
const buffer = Buffer.from(await file.arrayBuffer());
const uploaded = await uploadFile(buffer, file.name, file.type, "image");
const { key: tmplKey } = await uploadToHetzner(buffer, file.name, file.type, "image");
const uploaded = { url: `/api/files/${tmplKey}`, key: tmplKey };
const maxOrder = await db.sketchTemplate.aggregate({ _max: { sortOrder: true } });
const sortOrder = (maxOrder._max.sortOrder ?? -1) + 1;