From 9c5edc4f3e4df074baa5d658dca6098cd3731d71 Mon Sep 17 00:00:00 2001 From: Anikesh Suresh Date: Tue, 14 Jan 2025 11:50:41 +0000 Subject: [PATCH] fix download change commit later --- src/common/downloadFileDialog.component.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/downloadFileDialog.component.tsx b/src/common/downloadFileDialog.component.tsx index a5298fc7d..1ea538e4f 100644 --- a/src/common/downloadFileDialog.component.tsx +++ b/src/common/downloadFileDialog.component.tsx @@ -63,14 +63,18 @@ const DownloadFileDialog = (props: DownloadFileProps) => { const handleDownloadImages = React.useCallback(() => { if (downloadedImages && downloadedImages.length >= 1) { - downloadedImages.forEach((image: APIImageWithURL | undefined) => { + downloadedImages.forEach(async (image: APIImageWithURL | undefined) => { if (image) { - const link = document.createElement('iframe'); - link.src = image.url; - link.setAttribute('sandbox', 'allow-scripts allow-downloads'); - link.setAttribute('display', 'inline: none'); + const response = await fetch(image.url); + const blob = await response.blob(); + + const link = document.createElement('a'); + link.href = URL.createObjectURL(blob); + link.download = image.file_name; document.body.appendChild(link); link.click(); + URL.revokeObjectURL(link.href); + document.body.removeChild(link); } }); onChangeSelectedImages({});