Skip to content

Commit

Permalink
Request pay 6.x (ali-sdk#583)
Browse files Browse the repository at this point in the history
* feat:6.1.0 support requestPayer

* chore: fix bower.json version

* chore: eslint remote  off rule
  • Loading branch information
luozhang002 authored and binghaiwang committed Jan 7, 2019
1 parent 35c729f commit 4f2c8a0
Show file tree
Hide file tree
Showing 10 changed files with 5,595 additions and 5,564 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module.exports = {
}],
// wait node version >= 5.10.0 will start this rule
'no-buffer-constructor': [0],
"comma-dangle": [2, "never"],
"no-tabs":"off"
"comma-dangle": [2, "never"]
}
};
20 changes: 15 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="6.0.2"></a>
## [6.0.2](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.1.0...v6.0.2) (2018-12-10)
<a name="6.1.0"></a>
## [6.1.0](https://github.com/aliyun/oss-nodejs-sdk/compare/v6.0.2...v6.1.0) (2019-01-06)

### Features
* support requestPayer

### Bug Fixes

* repair codecov
* docs

<a name="6.0.2"></a>
## [6.0.2](https://github.com/aliyun/oss-nodejs-sdk/compare/v6.0.1...v6.0.2) (2018-12-10)

### Bug Fixes

Expand All @@ -14,7 +24,7 @@ All notable changes to this project will be documented in this file. See [standa


<a name="6.0.1"></a>
## [6.0.1](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.1.0...v6.0.1) (2018-07-17)
## [6.0.1](https://github.com/aliyun/oss-nodejs-sdk/compare/v6.0.0...v6.0.1) (2018-07-17)


### Bug Fixes
Expand All @@ -37,7 +47,7 @@ All notable changes to this project will be documented in this file. See [standa
* README.md example

<a name="5.3.2"></a>
## [5.3.2](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.1.0...v5.3.2) (2018-07-17)
## [5.3.2](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.3.1...v5.3.2) (2018-07-17)


### Bug Fixes
Expand All @@ -46,7 +56,7 @@ All notable changes to this project will be documented in this file. See [standa


<a name="5.3.1"></a>
# [5.3.1](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.1.0...v5.3.1) (2018-06-27)
# [5.3.1](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.3.0...v5.3.1) (2018-06-27)

### Bug Fixes

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ options:
- [internal] {Boolean} access OSS with aliyun internal network or not, default is `false`.
If your servers are running on aliyun too, you can set `true` to save lot of money.
- [secure] {Boolean} instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol.
- [timeout] {String|Number} instance level timeout for all operations, default is `60s`
- [timeout] {String|Number} instance level timeout for all operations, default is `60s`.
- [cname] {Boolean}, default false, access oss with custom domain name. if true, you can fill `endpoint` field with your custom domain name,
- [isRequestPay] {Boolean}, default false, whether request payer function of the bucket is open, if true, will send headers `'x-oss-request-payer': 'requester'` to oss server.
the details you can see [requestPay](https://help.aliyun.com/document_detail/91337.htm)

example:

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"package.json"
],
"main": "dist/aliyun-oss-sdk.js",
"version": "6.0.2"
"version": "6.1.0"
}
11,087 changes: 5,548 additions & 5,539 deletions dist/aliyun-oss-sdk.js

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions dist/aliyun-oss-sdk.min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion lib/browser/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ Client.initOptions = function initOptions(options) {
secure: isHttpsProtocol,
bucket: null,
endpoint: null,
cname: false
cname: false,
isRequestPay: false
};

Object.keys(options).forEach((key) => {
Expand Down Expand Up @@ -213,6 +214,10 @@ proto.createRequest = function createRequest(params) {
'x-oss-user-agent': this.userAgent
};

if (this.options.isRequestPay) {
Object.assign(headers, { 'x-oss-request-payer': 'requester' });
}

if (this.options.stsToken) {
headers['x-oss-security-token'] = this.options.stsToken;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exports.version="6.0.2"
exports.version="6.1.0"
7 changes: 6 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ Client.initOptions = function initOptions(options) {
timeout: 60000, // 60s
bucket: null,
endpoint: null,
cname: false
cname: false,
isRequestPay: false
};

Object.keys(options).forEach((key) => {
Expand Down Expand Up @@ -223,6 +224,10 @@ proto.createRequest = function createRequest(params) {
'User-Agent': this.userAgent
};

if (this.options.isRequestPay) {
Object.assign(headers, { 'x-oss-request-payer': 'requester' });
}

if (this.options.stsToken) {
headers['x-oss-security-token'] = this.options.stsToken;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ali-oss",
"version": "6.0.2",
"version": "6.1.0",
"description": "aliyun oss(object storage service) node client",
"main": "lib/client.js",
"files": [
Expand Down

0 comments on commit 4f2c8a0

Please sign in to comment.