fixed download link for share page

This commit is contained in:
2025-04-14 16:02:14 +02:00
parent 95392aa593
commit b4eb2b4657
3 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ export default function FileGrid({ session }: FileGridProps) {
const handleDownload = async (fileName: string) => {
try {
const response = await fetch(`/api/files/download?fileName=${encodeURIComponent(fileName)}`);
const response = await fetch(`/api/files/download?fileId=${encodeURIComponent(fileName)}`);
if (!response.ok) {
throw new Error("Failed to download file");
}
+1 -1
View File
@@ -4,7 +4,7 @@ import { promises as fs } from "fs";
export async function GET(req: Request) {
const url = new URL(req.url);
const fileId = url.searchParams.get("fileName");
const fileId = url.searchParams.get("fileId");
if (!fileId) {
return NextResponse.json({ error: "File id is required" }, { status: 400 });
+5 -1
View File
@@ -51,7 +51,11 @@ function UploadsPage() {
const handleDownload = async () => {
try {
const response = await fetch(`/api/files/download?fileId=${encodeURIComponent(fileDetails?.name ?? "")}`); // Use optional chaining
if (!fileDetails) {
toast.error("File details not available.");
return;
}
const response = await fetch(`/api/files/download?fileId=${encodeURIComponent(fileDetails?.name)}`); // Use optional chaining
if (!response.ok) {
throw new Error("Failed to download file");
}