UNPKG

ks3-js-sdk

Version:

js sdk for ks3

114 lines 4.34 kB
var uploadMultipart = function() { describe('分块上传文件', function () { let key = 'demo.txt'; let file = blob({ size: 1024 * 1024 * 5 }); describe('分块上传文件,不设置acl', function () { it('分块上传文件,不设置acl', function (done) { this.timeout(5000); ks3.uploadMultiPart({ key, file }, function (res) { should.not.exist(res.error); res.statusCode.should.be.equal(200); done(); }) }) it('获取该文件的ACL', function (done) { this.timeout(2000); ks3.getObjectAcl({ key }).then(res => { let grant = res.body.AccessControlPolicy.AccessControlList.Grant; grant.Permission.should.be.equal('FULL_CONTROL'); should.not.exist(res.error); res.statusCode.should.be.equal(200); done(); }) }) it('删除该文件', function (done) { this.timeout(2000); ks3.delObject({ key }).then(res => { should.not.exist(res.error); res.statusCode.should.be.equal(204); done(); }) }) }) describe('分块上传文件,设置acl为private', function () { it('分块上传文件,设置acl为private', function (done) { this.timeout(5000); ks3.uploadMultiPart({ key, file, acl: 'private' }, function (res) { should.not.exist(res.error); res.statusCode.should.be.equal(200); done(); }) }) it('获取该文件的ACL', function (done) { this.timeout(2000); ks3.getObjectAcl({ key }).then(res => { let grant = res.body.AccessControlPolicy.AccessControlList.Grant; grant.Permission.should.be.equal('FULL_CONTROL'); should.not.exist(res.error); res.statusCode.should.be.equal(200); done(); }) }) it('删除该文件', function (done) { this.timeout(2000); ks3.delObject({ key }).then(res => { should.not.exist(res.error); res.statusCode.should.be.equal(204); done(); }) }) }) describe('分块上传文件,设置acl为public-read', function () { it('分块上传文件,设置acl为public-read', function (done) { this.timeout(5000); ks3.uploadMultiPart({ key, file, acl: 'public-read' }, function (res) { should.not.exist(res.error); res.statusCode.should.be.equal(200); done(); }) }) it('获取该文件的ACL', function (done) { this.timeout(2000); ks3.getObjectAcl({ key }).then(res => { let grant = res.body.AccessControlPolicy.AccessControlList.Grant; grant[0].Permission.should.be.equal('FULL_CONTROL'); grant[1].Permission.should.be.equal('READ'); should.not.exist(res.error); res.statusCode.should.be.equal(200); done(); }) }) it('删除该文件', function (done) { this.timeout(2000); ks3.delObject({ key }).then(res => { should.not.exist(res.error); res.statusCode.should.be.equal(204); done(); }) }) }) }) }