From 8d61be329ea232659cf47123a156d9c810350bda Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Wed, 20 Mar 2024 10:14:30 +0100 Subject: [PATCH 1/2] Download archive as zip instead of tar in resource container --- src/shared/components/Preview/Preview.tsx | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/shared/components/Preview/Preview.tsx b/src/shared/components/Preview/Preview.tsx index 970e0ff1b..2490b9b36 100644 --- a/src/shared/components/Preview/Preview.tsx +++ b/src/shared/components/Preview/Preview.tsx @@ -176,22 +176,26 @@ const Preview: React.FC<{ body: JSON.stringify(payload), } ); + const archive = await nexus.httpGet({ + path: `${apiEndpoint}/archives/${orgLabel}/${projectLabel}/${payload.archiveId}?ignoreNotFound=true`, + headers: { accept: 'application/zip, application/json' }, + context: { + parseAs: 'blob', + }, + }); + const blob = archive as Blob; + const archiveName = `data-${payload.archiveId}.zip`; + downloadBlobHelper(blob, archiveName); + + notification.success({ + message: `Archive ${archiveName} downloaded successfully`, + }); } catch (error) { notification.error({ message: 'Failed to download the file', description: (error as TError).reason || (error as TError).message, }); } - const archive = (await nexus.Archive.get( - orgLabel, - projectLabel, - archiveId, - { - as: 'x-tar', - } - )) as string; - const blob = new Blob([archive]); - downloadBlobHelper(blob, `${archiveId}.tar.gz`); }; const downloadButton = (disabled: boolean) => { From 5c51c2ff51c27ff8932dff4dd613651cbcbc0e25 Mon Sep 17 00:00:00 2001 From: Dinika Saxena Date: Wed, 20 Mar 2024 10:20:17 +0100 Subject: [PATCH 2/2] Download archive as zip instead of tar in resource container Signed-off-by: Dinika Saxena --- src/shared/components/Preview/Preview.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared/components/Preview/Preview.tsx b/src/shared/components/Preview/Preview.tsx index 2490b9b36..0683ce47d 100644 --- a/src/shared/components/Preview/Preview.tsx +++ b/src/shared/components/Preview/Preview.tsx @@ -17,6 +17,7 @@ import { useSelector } from 'react-redux'; import { RootState } from '../../store/reducers'; import nexusUrlHardEncode from '../../utils/nexusEncode'; import { TError } from '../../../utils/types'; +import * as Sentry from '@sentry/browser'; export const parseResourceId = (url: string) => { const fileUrlPattern = /files\/([\w-]+)\/([\w-]+)\/(.*)/; @@ -191,6 +192,7 @@ const Preview: React.FC<{ message: `Archive ${archiveName} downloaded successfully`, }); } catch (error) { + Sentry.captureException({ error, message: 'Failed to download archive' }); notification.error({ message: 'Failed to download the file', description: (error as TError).reason || (error as TError).message,