fixed download link for share page
This commit is contained in:
parent
95392aa593
commit
b4eb2b4657
@ -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");
|
||||
}
|
||||
|
||||
@ -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 });
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user