This commit is contained in:
asabizanjo
2025-12-11 01:05:24 +00:00
parent c713d58f98
commit 423ce1bc6d
88 changed files with 4081 additions and 122 deletions

View File

@@ -0,0 +1,29 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/db";
import { getSessionUser } from "@/lib/auth";
import { getSignedDownloadUrl } from "@/lib/r2";
type Props = {
params: Promise<{ id: string }>;
};
export async function GET(_req: Request, { params }: Props) {
const session = await getSessionUser();
if (!session) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const { id } = await params;
const file = await prisma.file.findFirst({
where: { id, userId: session.userId },
});
if (!file) {
return NextResponse.json({ error: "File not found" }, { status: 404 });
}
const url = await getSignedDownloadUrl(file.key);
return NextResponse.json({ url, name: file.name });
}