Skip to content

Commit

Permalink
Merge pull request #87 from leotian/master
Browse files Browse the repository at this point in the history
perf(getobject): optimize getObject
  • Loading branch information
lurunze1226 authored May 6, 2022
2 parents 7843ba8 + 7098df1 commit d0e9a26
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.0.0-rc.35(2022-05-05)

- BOSClient: Just keep an array of all of buffers and concat at the end.

## 1.0.0-rc.34(2021-12-15)

- BOSClient: Provide cname_enabled field when using a custom domain name to delete bucketName path.
Expand Down
13 changes: 6 additions & 7 deletions dist/baidubce-sdk.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -22222,7 +22222,7 @@ module.exports={
"_args": [
[
"[email protected]",
"/Users/hanxiao11/console-project/github/my/bce-sdk-js"
"/Users/tianyanbo/Workspace/baidu/bce-sdk-js"
]
],
"_development": true,
Expand All @@ -22248,7 +22248,7 @@ module.exports={
],
"_resolved": "http://registry.npm.baidu-int.com/elliptic/-/elliptic-6.5.2.tgz",
"_spec": "6.5.2",
"_where": "/Users/hanxiao11/console-project/github/my/bce-sdk-js",
"_where": "/Users/tianyanbo/Workspace/baidu/bce-sdk-js",
"author": {
"name": "Fedor Indutny",
"email": "[email protected]"
Expand Down Expand Up @@ -46167,7 +46167,7 @@ BosClient.prototype.getObject = function (bucketName, key, range, options) {
config: options.config,
outputStream: outputStream
}).then(function (response) {
response.body = outputStream.store;
response.body = Buffer.concat(outputStream);
return response;
});
};
Expand Down Expand Up @@ -48331,8 +48331,7 @@ Document.prototype.download = function (documentId) {
* 1. The BOS bucket must in bj-region.
* 2. The BOS bucket permission must be public-read.
*
* 用户需要将源文档所在BOS bucket权限设置为公共读,或者在自定义权限设置中为开放云文档转码服务账号
*(沙盒:798c20fa770840438a29efd66cdccf7f,线上:183db8cd3d5a4bf9a94459f89a7a3a91)添加READ权限。
* 用户需要将源文档所在BOS bucket权限设置为公共读,或者在自定义权限设置中为开放云文档转码服务账号添加READ权限。
*
* 文档转码服务依赖文档的md5,为提高转码性能,文档转码服务需要用户为源文档指定md5;
* 因此用户需要在上传文档至BOS时设置自定义meta header x-bce-meta-md5来记录源文档md5。
Expand Down Expand Up @@ -53638,13 +53637,13 @@ var util = require('util');
function WMStream() {
stream.Writable.call(this);

this.store = new Buffer('');
this.store = [];
}
util.inherits(WMStream, stream.Writable);

WMStream.prototype._write = function (chunk, enc, cb) {
var buffer = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk, enc);
this.store = Buffer.concat([this.store, buffer]);
this.store.push(buffer);

cb();
};
Expand Down
6 changes: 3 additions & 3 deletions dist/baidubce-sdk.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@baiducloud/sdk",
"version": "1.0.0-rc.34",
"version": "1.0.0-rc.35",
"description": "Baidu Cloud Engine JavaScript SDK",
"main": "./index.js",
"browser": {
Expand Down
2 changes: 1 addition & 1 deletion src/bos_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ BosClient.prototype.getObject = function (bucketName, key, range, options) {
config: options.config,
outputStream: outputStream
}).then(function (response) {
response.body = outputStream.store;
response.body = Buffer.concat(outputStream);
return response;
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/wm_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ var util = require('util');
function WMStream() {
stream.Writable.call(this);

this.store = new Buffer('');
this.store = [];
}
util.inherits(WMStream, stream.Writable);

WMStream.prototype._write = function (chunk, enc, cb) {
var buffer = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk, enc);
this.store = Buffer.concat([this.store, buffer]);
this.store.push(buffer);

cb();
};
Expand Down
6 changes: 3 additions & 3 deletions test/browser/baidubce-sdk.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -29730,7 +29730,7 @@ BosClient.prototype.getObject = function (bucketName, key, range, options) {
config: options.config,
outputStream: outputStream
}).then(function (response) {
response.body = outputStream.store;
response.body = Buffer.concat(outputStream.store);
return response;
});
};
Expand Down Expand Up @@ -34022,13 +34022,13 @@ var util = require('util');
function WMStream() {
stream.Writable.call(this);

this.store = new Buffer('');
this.store = [];
}
util.inherits(WMStream, stream.Writable);

WMStream.prototype._write = function (chunk, enc, cb) {
var buffer = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk, enc);
this.store = Buffer.concat([this.store, buffer]);
this.store.push(buffer);

cb();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29730,7 +29730,7 @@ BosClient.prototype.getObject = function (bucketName, key, range, options) {
config: options.config,
outputStream: outputStream
}).then(function (response) {
response.body = outputStream.store;
response.body = Buffer.concat(outputStream.store);
return response;
});
};
Expand Down Expand Up @@ -34022,13 +34022,13 @@ var util = require('util');
function WMStream() {
stream.Writable.call(this);

this.store = new Buffer('');
this.store = [];
}
util.inherits(WMStream, stream.Writable);

WMStream.prototype._write = function (chunk, enc, cb) {
var buffer = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk, enc);
this.store = Buffer.concat([this.store, buffer]);
this.store.push(buffer);

cb();
};
Expand Down
6 changes: 3 additions & 3 deletions test/browser/demo/samples/dep/baidubce-sdk.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -29730,7 +29730,7 @@ BosClient.prototype.getObject = function (bucketName, key, range, options) {
config: options.config,
outputStream: outputStream
}).then(function (response) {
response.body = outputStream.store;
response.body = Buffer.concat(outputStream.store);
return response;
});
};
Expand Down Expand Up @@ -34022,13 +34022,13 @@ var util = require('util');
function WMStream() {
stream.Writable.call(this);

this.store = new Buffer('');
this.store = [];
}
util.inherits(WMStream, stream.Writable);

WMStream.prototype._write = function (chunk, enc, cb) {
var buffer = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk, enc);
this.store = Buffer.concat([this.store, buffer]);
this.store.push(buffer);

cb();
};
Expand Down
5 changes: 3 additions & 2 deletions test/sdk/http_client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ describe('HttpClient', function() {
var client = new HttpClient(config);

var output_stream = new WMStream();
var output_stream_buffer = Buffer.concat(output_stream.store);
return client.sendRequest('GET', '/v1', null, null, null, sign_function, output_stream)
.then(function(response) {
expect(response.body).to.eql({});
expect(output_stream.store.length).to.be.greaterThan(0);
var owner = JSON.parse(output_stream.store.toString()).owner;
expect(output_stream_buffer.length).to.be.greaterThan(0);
var owner = JSON.parse(output_stream_buffer.toString()).owner;
expect(owner).to.eql(config.account);
});
});
Expand Down

0 comments on commit d0e9a26

Please sign in to comment.