Files
twotalesanimation b683976cc6
Deploy / deploy (push) Successful in 3m16s
High res uploads
2026-06-25 09:56:41 +02:00

30 lines
958 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { generateHetznerDownloadUrl } from "@/lib/storage";
/** GET /api/shots/[shotId]/highres/download — returns a short-lived presigned download URL */
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ shotId: string }> }
) {
const session = await auth();
if (!session?.user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const { shotId } = await params;
const shot = await db.shot.findUnique({
where: { id: shotId },
select: { highResKey: true, highResFilename: true },
});
if (!shot?.highResKey || !shot?.highResFilename) {
return NextResponse.json({ error: "No high-res file available" }, { status: 404 });
}
const url = await generateHetznerDownloadUrl(shot.highResKey, shot.highResFilename);
return NextResponse.json({ url });
}