Skip to content

Commit

Permalink
优化接口返回值
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Nov 5, 2017
1 parent 525ccae commit 8f009f9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 11 deletions.
27 changes: 23 additions & 4 deletions dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,7 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.2.0';
COS.version = '0.2.1';

module.exports = window.COS = COS;

Expand Down Expand Up @@ -3792,7 +3792,17 @@ function getBucketCors(params, callback) {
action: '/?cors'
}, function (err, data) {
if (err) {
return callback(err);
if (err.statusCode === 404 && err.error && err.error.Code === 'NoSuchCORSConfiguration') {
var result = {
CORSRules: [],
statusCode: err.statusCode
};
err.headers && (result.headers = err.headers);
callback(null, result);
} else {
callback(err);
}
return;
}
var CORSConfiguration = data.CORSConfiguration || {};
var CORSRules = CORSConfiguration.CORSRules || CORSConfiguration.CORSRule || [];
Expand Down Expand Up @@ -4143,7 +4153,17 @@ function getBucketLifecycle(params, callback) {
action: '/?lifecycle'
}, function (err, data) {
if (err) {
return callback(err);
if (err.statusCode === 404 && err.error && err.error.Code === 'NoSuchLifecycleConfiguration') {
var result = {
Rules: [],
statusCode: err.statusCode
};
err.headers && (result.headers = err.headers);
callback(null, result);
} else {
callback(err);
}
return;
}
var Rules = [];
try {
Expand Down Expand Up @@ -9666,7 +9686,6 @@ function sliceUploadFile(params, callback) {

var onProgress = params.onProgress;
var onHashProgress = params.onHashProgress;
StorageClass = null;

// 上传过程中出现错误,返回错误
ep.on('error', function (err) {
Expand Down
4 changes: 2 additions & 2 deletions dist/cos-js-sdk-v5.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": "cos-js-sdk-v5",
"version": "0.2.0",
"version": "0.2.1",
"description": "cos js sdk v5",
"main": "index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function sliceUploadFile(params, callback) {

var onProgress = params.onProgress;
var onHashProgress = params.onHashProgress;
StorageClass = null;

// 上传过程中出现错误,返回错误
ep.on('error', function (err) {
Expand Down
24 changes: 22 additions & 2 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,17 @@ function getBucketCors(params, callback) {
action: '/?cors',
}, function (err, data) {
if (err) {
return callback(err);
if (err.statusCode === 404 && err.error && err.error.Code === 'NoSuchCORSConfiguration') {
var result = {
CORSRules: [],
statusCode: err.statusCode,
};
err.headers && (result.headers = err.headers);
callback(null, result);
} else {
callback(err);
}
return;
}
var CORSConfiguration = data.CORSConfiguration || {};
var CORSRules = CORSConfiguration.CORSRules || CORSConfiguration.CORSRule || [];
Expand Down Expand Up @@ -596,7 +606,17 @@ function getBucketLifecycle(params, callback) {
action: '/?lifecycle',
}, function (err, data) {
if (err) {
return callback(err);
if (err.statusCode === 404 && err.error && err.error.Code === 'NoSuchLifecycleConfiguration') {
var result = {
Rules: [],
statusCode: err.statusCode,
};
err.headers && (result.headers = err.headers);
callback(null, result);
} else {
callback(err);
}
return;
}
var Rules = [];
try {
Expand Down
2 changes: 1 addition & 1 deletion src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.2.0';
COS.version = '0.2.1';

module.exports = window.COS = COS;

0 comments on commit 8f009f9

Please sign in to comment.