@@ -16,6 +16,7 @@ import TableViewerContainer from '../../containers/TableViewerContainer';
1616import { useSelector } from 'react-redux' ;
1717import { RootState } from '../../store/reducers' ;
1818import nexusUrlHardEncode from '../../utils/nexusEncode' ;
19+ import * as Sentry from '@sentry/browser' ;
1920
2021export const parseResourceId = ( url : string ) => {
2122 const fileUrlPattern = / f i l e s \/ ( [ \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