Skip to content

Commit

Permalink
添加两个接口 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu authored and carsonxu committed Apr 24, 2017
1 parent d490cfb commit d907c4b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
node_modules
/demo/*.zip
21 changes: 21 additions & 0 deletions demo/PutObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var path = require('path');
var fs = require('fs');
var COS = require('../sdk/cos');
var filename = '1mb.zip'
var filepath = path.resolve(__dirname, '1mb.zip');

var params = {
Bucket : 'coco', /* 必须 */
Region : 'cn-south', //cn-south、cn-north、cn-east /* 必须 */
Key : '1mb.zip', /* 必须 */
Body : filepath, /* 必须 */
ContentLength : fs.statSync(filepath).size, /* 必须 */
};

COS.putObject(params, function(err, data) {
if(err) {
console.log(err);
} else {
console.log(data);
}
});
24 changes: 24 additions & 0 deletions demo/SliceUploadFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var path = require('path');
var COS = require('../sdk/advanced_api');
var filepath = path.resolve(__dirname, '40mb.zip');

var params = {
Bucket : 'coco', /* 必须 */
Region : 'cn-south', //cn-south、cn-north、cn-east /* 必须 */
Key : '40mb.zip', /* 必须 */
FilePath : filepath, /* 必须 */
SliceSize : 1024 * 1024, //1MB /* 非必须 */
AsyncLimit : 5 /* 非必须 */
};

var ProgressCallback = function(progressData) {
console.log(progressData);
};

COS.sliceUploadFile(params, function(err, data) {
if(err) {
console.log(err);
} else {
console.log(data);
}
}, ProgressCallback);

0 comments on commit d907c4b

Please sign in to comment.