High res uploads
Deploy / deploy (push) Successful in 3m16s

This commit is contained in:
twotalesanimation
2026-06-25 09:56:41 +02:00
parent d2e686335f
commit b683976cc6
9 changed files with 364 additions and 2 deletions
@@ -0,0 +1,37 @@
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { validateReviewToken } from "@/lib/review-auth";
import { generateHetznerDownloadUrl } from "@/lib/storage";
/**
* GET /api/client/[token]/shots/[shotId]/highres/download
* Validates the client review token then returns a presigned Hetzner download URL.
*/
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ token: string; shotId: string }> }
) {
const { token, shotId } = await params;
const result = await validateReviewToken(token, req);
if (result.type !== "ok") {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const shot = await db.shot.findUnique({
where: { id: shotId },
select: { highResKey: true, highResFilename: true, projectId: true },
});
// Ensure the shot belongs to the review session's project
if (!shot || shot.projectId !== result.session.projectId) {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
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 });
}