Skip to content

Commit

Permalink
修改 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Nov 13, 2018
1 parent 810ef03 commit e25a475
Showing 1 changed file with 52 additions and 9 deletions.
61 changes: 52 additions & 9 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function getBucket() {
cos.getBucket({
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Region: config.Region,
// Prefix: ''
// Prefix: 'dir/'
// Delimiter: '/'
}, function (err, data) {
logger.log(err || data);
Expand Down Expand Up @@ -250,16 +250,58 @@ function putBucketPolicy() {
"effect": "allow",
"principal": {"qcs": ["qcs::cam::uin/10001:uin/10001"]}, // 这里的 10001 是 QQ 号
"action": [
"name/cos:PutObject",
"name/cos:InitiateMultipartUpload",
"name/cos:ListMultipartUploads",
"name/cos:ListParts",
"name/cos:UploadPart",
"name/cos:CompleteMultipartUpload"
// 这里可以从临时密钥的权限上控制前端允许的操作
// 'name/cos:*', // 这样写可以包含下面所有权限

// // 列出所有允许的操作
// // ACL 读写
// 'name/cos:GetBucketACL',
// 'name/cos:PutBucketACL',
// 'name/cos:GetObjectACL',
// 'name/cos:PutObjectACL',
// // 简单 Bucket 操作
// 'name/cos:PutBucket',
// 'name/cos:HeadBucket',
// 'name/cos:GetBucket',
// 'name/cos:DeleteBucket',
// 'name/cos:GetBucketLocation',
// // Versioning
// 'name/cos:PutBucketVersioning',
// 'name/cos:GetBucketVersioning',
// // CORS
// 'name/cos:PutBucketCORS',
// 'name/cos:GetBucketCORS',
// 'name/cos:DeleteBucketCORS',
// // Lifecycle
// 'name/cos:PutBucketLifecycle',
// 'name/cos:GetBucketLifecycle',
// 'name/cos:DeleteBucketLifecycle',
// // Replication
// 'name/cos:PutBucketReplication',
// 'name/cos:GetBucketReplication',
// 'name/cos:DeleteBucketReplication',
// // 删除文件
// 'name/cos:DeleteMultipleObject',
// 'name/cos:DeleteObject',
// 简单文件操作
'name/cos:PutObject',
'name/cos:AppendObject',
'name/cos:GetObject',
'name/cos:HeadObject',
'name/cos:OptionsObject',
'name/cos:PutObjectCopy',
'name/cos:PostObjectRestore',
// 分片上传操作
'name/cos:InitiateMultipartUpload',
'name/cos:ListMultipartUploads',
'name/cos:ListParts',
'name/cos:UploadPart',
'name/cos:CompleteMultipartUpload',
'name/cos:AbortMultipartUpload',
],
// "resource": ["qcs::cos:ap-guangzhou:uid/1250000000:test-1250000000/*"] // 1250000000 是 appid
"resource": ["qcs::cos:" + config.Region + ":uid/" + AppId + ":" + config.Bucket + "/*"] // 1250000000 是 appid
}],
}]
},
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Region: config.Region
Expand Down Expand Up @@ -543,7 +585,8 @@ function deleteMultipleObject() {
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Region: config.Region,
Objects: [
{Key: '1mb.zip',VersionId: 'MTg0NDY3NDI1MzM4NzM0ODA2MTI'},
{Key: '中文/中文.txt'},
{Key: '中文/中文.zip',VersionId: 'MTg0NDY3NDI1MzM4NzM0ODA2MTI'},
]
}, function (err, data) {
logger.log(err || data);
Expand Down

0 comments on commit e25a475

Please sign in to comment.