@@ -15,11 +15,13 @@ import PT from 'prop-types';
1515import { connect } from 'react-redux' ;
1616import { Modal } from 'topcoder-react-ui-kit' ;
1717import { config } from 'topcoder-react-utils' ;
18- import { actions } from 'topcoder-react-lib' ;
18+ import { actions , services } from 'topcoder-react-lib' ;
1919
2020import './styles.scss' ;
2121import smpActions from '../../actions/page/submission_management' ;
2222
23+ const { getService } = services . submissions ;
24+
2325// The container component
2426class SubmissionManagementPageContainer extends React . Component {
2527 componentDidMount ( ) {
@@ -68,16 +70,17 @@ class SubmissionManagementPageContainer extends React.Component {
6870 onShowDetails,
6971 onDelete : onSubmissionDelete ,
7072 onDownload : ( challengeType , submissionId ) => {
71- // download large file using stream method
72- const downloadSubmissionURL = `${ config . URL . SUBMISSION_REVIEW_API_URL } /challengeSubmissions/${ submissionId } /download?token=${ authTokens . tokenV3 } ` ;
73-
74- const link = document . createElement ( 'a' ) ;
75- link . href = downloadSubmissionURL ;
76- link . setAttribute ( 'download' , `submission-${ challengeType } -${ submissionId } .zip` ) ;
77-
78- document . body . appendChild ( link ) ;
79- link . click ( ) ;
80- link . parentNode . removeChild ( link ) ;
73+ const submissionsService = getService ( authTokens . tokenV3 ) ;
74+ submissionsService . downloadSubmission ( submissionId )
75+ . then ( ( blob ) => {
76+ const url = window . URL . createObjectURL ( new Blob ( [ blob ] ) ) ;
77+ const link = document . createElement ( 'a' ) ;
78+ link . href = url ;
79+ link . setAttribute ( 'download' , `submission-${ challengeType } -${ submissionId } .zip` ) ;
80+ document . body . appendChild ( link ) ;
81+ link . click ( ) ;
82+ link . parentNode . removeChild ( link ) ;
83+ } ) ;
8184 } ,
8285 onlineReviewUrl : `${ config . URL . ONLINE_REVIEW } /review/actions/ViewProjectDetails?pid=${ challengeId } ` ,
8386 challengeUrl : `${ challengesUrl } /${ challengeId } ` ,
0 commit comments