Skip to content

Commit

Permalink
feat: expose sdk version with OSS (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
binghaiwang authored and PeterRao committed Mar 16, 2018
1 parent 02fef3f commit 0bdc876
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var appServer = '/sts';
var bucket = '<bucket-name>';
var region = 'oss-cn-hangzhou';
var Buffer = OSS.Buffer;
var OSS = OSS.Wrapper;

// Play without STS. NOT SAFE! Because access key id/secret are
// exposed in web page.
Expand All @@ -23,7 +22,6 @@ var OSS = OSS.Wrapper;
// var applyTokenDo = function (func) {
// return func(client);
// };

var applyTokenDo = function (func, refreshSts) {
var refresh = typeof(refreshSts) !== 'undefined' ? refreshSts : true;
if (refresh) {
Expand All @@ -32,14 +30,15 @@ var applyTokenDo = function (func, refreshSts) {
url: url
}).then(function (result) {
var creds = result;
var client = new OSS({
var client = new OSS.Wrapper({
region: region,
accessKeyId: creds.AccessKeyId,
accessKeySecret: creds.AccessKeySecret,
stsToken: creds.SecurityToken,
bucket: bucket
});

console.log(OSS.version);
return func(client);
});
} else {
Expand Down
1 change: 1 addition & 0 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ var OSS = require('./browser/client');
OSS.Buffer = require('buffer').Buffer;
OSS.co = require('co');
OSS.urllib = require('../shims/xhr');
OSS.version = require('./browser/version').version;

module.exports = OSS;

0 comments on commit 0bdc876

Please sign in to comment.