Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit af3f9f2

Browse files
authored
Merge pull request #1527 from BlueBrain/develop
Develop
2 parents 0d630b5 + e18e42f commit af3f9f2

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/shared/components/Preview/Preview.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import TableViewerContainer from '../../containers/TableViewerContainer';
1616
import { useSelector } from 'react-redux';
1717
import { RootState } from '../../store/reducers';
1818
import nexusUrlHardEncode from '../../utils/nexusEncode';
19+
import * as Sentry from '@sentry/browser';
1920

2021
export const parseResourceId = (url: string) => {
2122
const fileUrlPattern = /files\/([\w-]+)\/([\w-]+)\/(.*)/;
@@ -169,22 +170,27 @@ const Preview: React.FC<{
169170
body: JSON.stringify(payload),
170171
}
171172
);
173+
const archive = await nexus.httpGet({
174+
path: `${apiEndpoint}/archives/${orgLabel}/${projectLabel}/${payload.archiveId}?ignoreNotFound=true`,
175+
headers: { accept: 'application/zip, application/json' },
176+
context: {
177+
parseAs: 'blob',
178+
},
179+
});
180+
const blob = archive as Blob;
181+
const archiveName = `data-${payload.archiveId}.zip`;
182+
downloadBlobHelper(blob, archiveName);
183+
184+
notification.success({
185+
message: `Archive ${archiveName} downloaded successfully`,
186+
});
172187
} catch (error) {
188+
Sentry.captureException({ error, message: 'Failed to download archive' });
173189
notification.error({
174190
message: 'Failed to download the file',
175191
description: error.reason || error.message,
176192
});
177193
}
178-
const archive = (await nexus.Archive.get(
179-
orgLabel,
180-
projectLabel,
181-
archiveId,
182-
{
183-
as: 'x-tar',
184-
}
185-
)) as string;
186-
const blob = new Blob([archive]);
187-
downloadBlobHelper(blob, `${archiveId}.tar.gz`);
188194
};
189195

190196
const downloadButton = (disabled: boolean) => {

0 commit comments

Comments
 (0)