From 4afae4cc8493001826c1f5553a26c8974ae0641f Mon Sep 17 00:00:00 2001 From: Joel Mathew Thomas <90510078+joelmathewthomas@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:51:50 +0530 Subject: [PATCH] add logic for download --- client/src/Pages/ResultsPage.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/client/src/Pages/ResultsPage.tsx b/client/src/Pages/ResultsPage.tsx index dc80bfb..36988ba 100644 --- a/client/src/Pages/ResultsPage.tsx +++ b/client/src/Pages/ResultsPage.tsx @@ -28,6 +28,26 @@ function ResultsPage() { const mediaFileRef = useRef(null); const audioClass = response.audio_class const isVideo = mediaFile?.type.includes('video'); + + const handleDownloadAll = () => { + if (audioClass === 'Music') { + extractedFiles.forEach(({ name, url }) => { + const link = document.createElement('a'); + link.href = url; + link.download = name; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }); + } else { + const link = document.createElement('a'); + link.href = downloadedFileURL; + link.download = mediaFile?.name ?? 'downloaded_file'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } + }; useEffect(() => { if (!mediaFile) { @@ -163,7 +183,7 @@ function ResultsPage() { - +