Skip to content

Commit

Permalink
add task demo
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Jul 11, 2017
1 parent 2071721 commit 20a67b0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,17 @@ function abortUploadTask() {
});
}

var TaskId;
function sliceUploadFile() {
var blob = util.createFile({size: 1024 * 1024 * 10});
cos.sliceUploadFile({
Bucket: config.Bucket, /* 必须 */
Region: config.Region,
Key: '10mb.zip', /* 必须 */
Body: blob,
TaskReady: function (tid) {
TaskId = tid;
},
onHashProgress: function (progressData) {
console.log(JSON.stringify(progressData));
},
Expand All @@ -466,6 +470,30 @@ function sliceUploadFile() {
});
}

function cancelTask() {
sliceUploadFile();
setTimeout(function () {
cos.cancelTask(TaskId);
console.log('canceled');
}, 2000);
}

function pauseTask() {
sliceUploadFile();
setTimeout(function () {
cos.pauseTask(TaskId);
console.log('paused');
restartTask();
}, 2000);
}

function restartTask() {
setTimeout(function () {
cos.restartTask(TaskId);
console.log('restart');
}, 4000);
}

// getService();
// getAuth();
// putBucket();
Expand Down

0 comments on commit 20a67b0

Please sign in to comment.