-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
carsonxu
authored and
carsonxu
committed
Apr 24, 2017
1 parent
d490cfb
commit d907c4b
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
node_modules | ||
/demo/*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |