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

Commit 188a71c

Browse files
author
Nick Litwin
committedDec 30, 2015
Add callbacks for updating and processing endpoints
1 parent 5d54d7b commit 188a71c

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed
 

‎app/services/submissions.service.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
var status = xhr.status;
4848
if (((status >= 200 && status < 300) || status === 304) && xhr.readyState === 4) {
4949
$log.info('Successfully uploaded file');
50-
console.log(xhr.responseText);
51-
var xhrResponse = xhr.responseText;
50+
console.log('xhr response: ', xhr.responseXML);
51+
var xhrResponse = xhr.responseXML;
5252
deferred.resolve(xhrResponse);
5353

5454
} else if (status >= 400) {
@@ -78,12 +78,28 @@
7878
});
7979
}
8080

81-
function updateSubmissionStatus() {
82-
81+
function updateSubmissionStatus(id, data) {
82+
// Pass data from upload to S3
83+
return api.one('submissions', id).customPUT(data)
84+
.then(function(response) {
85+
$log.info('Successfully updated file status');
86+
})
87+
.catch(function(err) {
88+
$log.info('Error updating file status');
89+
$log.error(err);
90+
});
8391
}
8492

85-
function recordCompletedSubmission() {
86-
93+
function recordCompletedSubmission(id, data) {
94+
// Once all uploaded, make record and begin processing
95+
return api.one('submissions', id).customPOST(data, 'process')
96+
.then(function(response) {
97+
$log.info('Successfully made file record. Beginning processing');
98+
})
99+
.catch(function(err) {
100+
$log.info('Error in creating file record');
101+
$log.error(err);
102+
});
87103
}
88104
};
89105
})();

0 commit comments

Comments
 (0)
This repository has been archived.