Skip to content

Commit

Permalink
fix download change commit later
Browse files Browse the repository at this point in the history
  • Loading branch information
asuresh-code committed Jan 14, 2025
1 parent 908f55e commit 9c5edc4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/common/downloadFileDialog.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({});
Expand Down

0 comments on commit 9c5edc4

Please sign in to comment.