From 7133c544e15c52ea1ffb5e8c2cfa3ae00b9d41d6 Mon Sep 17 00:00:00 2001
From: ZareMate <0.zaremate@gmail.com>
Date: Tue, 15 Apr 2025 08:03:59 +0200
Subject: [PATCH] changed all things to use id instead of file name
---
 src/app/_components/FileGrid.tsx    |  8 ++---
 src/app/api/files/download/route.ts |  6 +++-
 src/app/api/remove/route.ts         |  2 +-
 src/app/api/share/route.ts          |  6 ++--
 src/app/api/upload/route.ts         |  8 +++--
 src/app/share/page.tsx              | 51 ++++++++++++++++-------------
 6 files changed, 48 insertions(+), 33 deletions(-)
diff --git a/src/app/_components/FileGrid.tsx b/src/app/_components/FileGrid.tsx
index 78db341..3525817 100644
--- a/src/app/_components/FileGrid.tsx
+++ b/src/app/_components/FileGrid.tsx
@@ -37,13 +37,13 @@ export default function FileGrid({ session }: FileGridProps) {
     }
   };
 
-  const handleDownload = async (fileName: string) => {
+  const handleDownload = async (fileId: string, fileName: string) => {
     try {
-      const response = await fetch(`/api/files/download?fileId=${encodeURIComponent(fileName)}`);
+      const response = await fetch(`/api/files/download?fileId=${encodeURIComponent(fileId)}&fileName=${encodeURIComponent(fileName)}`);
       if (!response.ok) {
         throw new Error("Failed to download file");
       }
-
+      // Download the file with the correct filename
       const blob = await response.blob();
       const url = window.URL.createObjectURL(blob);
       const a = document.createElement("a");
@@ -143,7 +143,7 @@ export default function FileGrid({ session }: FileGridProps) {
             
               {/* Download Button */}