Skip to content

Commit

Permalink
checkChunkUploadedByResponse demo
Browse files Browse the repository at this point in the history
  • Loading branch information
dolymood committed Oct 18, 2017
1 parent 6baf0be commit ab9f6c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/Node.js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ app.get('/upload', function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
}

res.status(status == 'found' ? 200 : 404).send(status);
res.status(status == 'found' ? 200 : 204).send(status);
});
});

Expand Down
12 changes: 11 additions & 1 deletion samples/Node.js/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
var r = new Uploader({
target: '/upload',
chunkSize: 1024 * 1024,
testChunks: false
testChunks: true,
checkChunkUploadedByResponse: function (chunk, message) {
var objMessage = {}
try {
objMessage = JSON.parse(message)
} catch (e) {}
// fake response
// objMessage.uploaded_chunks = [2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 17, 20, 21]
// check the chunk is uploaded
return (objMessage.uploaded_chunks || []).indexOf(chunk.offset + 1) >= 0
}
});
// simple-uploader.js isn't supported, fall back on a different method
if (!r.support) {
Expand Down

0 comments on commit ab9f6c6

Please sign in to comment.