diff --git a/src/shared/components/Preview/Preview.tsx b/src/shared/components/Preview/Preview.tsx index 8814039ca..6ae1e88b9 100644 --- a/src/shared/components/Preview/Preview.tsx +++ b/src/shared/components/Preview/Preview.tsx @@ -16,6 +16,7 @@ import TableViewerContainer from '../../containers/TableViewerContainer'; import { useSelector } from 'react-redux'; import { RootState } from '../../store/reducers'; import nexusUrlHardEncode from '../../utils/nexusEncode'; +import * as Sentry from '@sentry/browser'; export const parseResourceId = (url: string) => { const fileUrlPattern = /files\/([\w-]+)\/([\w-]+)\/(.*)/; @@ -169,22 +170,27 @@ 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) { + Sentry.captureException({ error, message: 'Failed to download archive' }); notification.error({ message: 'Failed to download the file', description: error.reason || error.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) => {