@@ -15,11 +15,13 @@ import PT from 'prop-types';
15
15
import { connect } from 'react-redux' ;
16
16
import { Modal } from 'topcoder-react-ui-kit' ;
17
17
import { config } from 'topcoder-react-utils' ;
18
- import { actions } from 'topcoder-react-lib' ;
18
+ import { actions , services } from 'topcoder-react-lib' ;
19
19
20
20
import './styles.scss' ;
21
21
import smpActions from '../../actions/page/submission_management' ;
22
22
23
+ const { getService } = services . submissions ;
24
+
23
25
// The container component
24
26
class SubmissionManagementPageContainer extends React . Component {
25
27
componentDidMount ( ) {
@@ -68,16 +70,17 @@ class SubmissionManagementPageContainer extends React.Component {
68
70
onShowDetails,
69
71
onDelete : onSubmissionDelete ,
70
72
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
+ } ) ;
81
84
} ,
82
85
onlineReviewUrl : `${ config . URL . ONLINE_REVIEW } /review/actions/ViewProjectDetails?pid=${ challengeId } ` ,
83
86
challengeUrl : `${ challengesUrl } /${ challengeId } ` ,
0 commit comments