This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user