changed all things to use id instead of file name

This commit is contained in:
2025-04-15 08:03:59 +02:00
parent b4eb2b4657
commit 7133c544e1
6 changed files with 48 additions and 33 deletions
+5 -1
View File
@@ -5,10 +5,14 @@ import { promises as fs } from "fs";
export async function GET(req: Request) {
const url = new URL(req.url);
const fileId = url.searchParams.get("fileId");
const fileName = url.searchParams.get("fileName");
if (!fileId) {
return NextResponse.json({ error: "File id is required" }, { status: 400 });
}
if (!fileName){
return NextResponse.json({ error: "File name is required" }, { status: 400 });
}
try {
const filePath = path.join(process.cwd(), "uploads", fileId);
@@ -17,7 +21,7 @@ export async function GET(req: Request) {
return new Response(fileBuffer, {
headers: {
"Content-Type": "application/octet-stream",
"Content-Disposition": `attachment; filename="${fileId}"`,
"Content-Disposition": `attachment; filename="${fileName}"`,
},
});
} catch (error) {