Skip to content

Commit

Permalink
update 3.24.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtingwei998 committed Apr 28, 2024
1 parent 3a56ebd commit 5cc75e2
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 15 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
Version 3.23.11
Version 3.24.3

New Features:
1. Added the abort upload to the ObsClient.uploadFile API.

Documentation & Demo: None

-----------------------------------------------------------------------------------

Version 3.23.11

New Features:
1. Added three API, ObsClient.setObjectTagging、ObsClient.getObjectTagging and ObsClient.deleteObjectTagging;
Expand Down
10 changes: 9 additions & 1 deletion README_CN.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Version 3.23.11
Version 3.24.3
新特性:
1. uploadFile方法新增取消上传任务功能;

资料&demo:无

-----------------------------------------------------------------------------------

Version 3.23.11
新特性:
1. 新增设置对象标签、获取对象标签和删除对象标签三个接口;
2. uploadFile方法支持指定Expires参数设置上传对象过期时间;
Expand Down
14 changes: 14 additions & 0 deletions lib/baseModel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
*/

const operations = {

'ListBuckets' : {
Expand Down
15 changes: 9 additions & 6 deletions lib/obs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*
*/


const util = require('util');
const Utils = require('./utils');
const LogUtil = require('./log');
Expand Down Expand Up @@ -480,7 +479,11 @@ ObsClient.prototype.uploadFile = function(param, callback){
cancel : function(){
isAbort = true;
_callback('Upload suspened', 'The process of uploadFile is suspened, you can try again')
}
},
abort : function(){
isAbort = true;
abortRequest(uploadCheckpoint, checkpointFile, 'Upload isAbort', 'The process of uploadFile is isAbort');
},
});

let progressCallbacks = function(partNumber, loaded){
Expand Down Expand Up @@ -576,6 +579,9 @@ ObsClient.prototype.uploadFile = function(param, callback){
SseCKey : uploadCheckpoint.sseCKey,
ProgressCallback : createProgressCallbackByPartNumber(partNumber),
}, function(err, result) {
if(isAbort){
return
}
let partMeta = {offset : offset, partSize : currPartSize};
if(err || result.CommonMsg.Status >= 500){
partMeta.isCompleted = false;
Expand All @@ -596,9 +602,6 @@ ObsClient.prototype.uploadFile = function(param, callback){
if(checkpointFile && !writeCheckpointFileSync(checkpointFile, uploadCheckpoint)){
return;
}
if(isAbort){
return;
}
finishedCount++;
finishedCountGroup++;
let _taskNum = (currentGroupIndex === groupCount) ? (uploadCheckpoint.partCount - (currentGroupIndex - 1) * taskNum) : taskNum;
Expand Down Expand Up @@ -1496,7 +1499,7 @@ ObsClient.prototype.factory = function(param){
this.util.initFactory(param.access_key_id, param.secret_access_key, param.is_secure,
param.server, param.path_style, param.signature, param.region, param.port, param.max_retry_count,
param.timeout, param.ssl_verify, param.long_conn_param, param.security_token, param.is_signature_negotiation, param.is_cname,
param.max_connections, param.http_agent, param.https_agent, param.user_agent);
param.max_connections, param.http_agent, param.https_agent, param.user_agent, param.third_http_lib, param.no_proxy_list);
};

ObsClient.prototype.refresh = function(access_key_id, secret_access_key, security_token){
Expand Down
37 changes: 36 additions & 1 deletion lib/obsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,23 @@ const operations = {
'sentAs' : 'meta-',
'withPrefix' : true,
},
'CacheControl': {
'location': 'header',
'sentAs': 'Cache-Control'
},
'ContentDisposition': {
'location': 'header',
'sentAs': 'Content-Disposition',
'encodingSafe': ' ;/?:@&=+$,"'
},
'ContentLanguage': {
'location': 'header',
'sentAs': 'Content-Language'
},
'ContentEncoding': {
'location': 'header',
'sentAs': 'Content-Encoding'
},
'WebsiteRedirectLocation' : {
'location' : 'header',
'sentAs' : 'website-redirect-location',
Expand Down Expand Up @@ -3391,7 +3408,8 @@ const operations = {
},
'ContentDisposition': {
'location': 'header',
'sentAs': 'Content-Disposition'
'sentAs': 'Content-Disposition',
'encodingSafe': ' ;/?:@&=+$,"'
},
'ContentLanguage': {
'location': 'header',
Expand Down Expand Up @@ -3901,6 +3919,23 @@ const operations = {
'sentAs' : 'meta-',
'withPrefix' : true
},
'CacheControl': {
'location': 'header',
'sentAs': 'Cache-Control'
},
'ContentDisposition': {
'location': 'header',
'sentAs': 'Content-Disposition',
'encodingSafe': ' ;/?:@&=+$,"'
},
'ContentLanguage': {
'location': 'header',
'sentAs': 'Content-Language'
},
'ContentEncoding': {
'location': 'header',
'sentAs': 'Content-Encoding'
},
'WebsiteRedirectLocation' : {
'location' : 'header',
'sentAs' : 'website-redirect-location',
Expand Down
31 changes: 27 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*
*/


const crypto = require('crypto');
const fs = require('fs');
const events = require('events');
Expand All @@ -35,7 +34,7 @@ const options = {
const parser = new XMLParser(options);

const CONTENT_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
const OBS_SDK_VERSION = '3.23.11';
const OBS_SDK_VERSION = '3.24.3';

const mimeTypes = {
'7z' : 'application/x-7z-compressed',
Expand Down Expand Up @@ -497,6 +496,7 @@ function Utils(logger) {
this.sslVerify = false;
this.httpAgent = false;
this.httpsAgent = false;
this.noProxyList = [];
this.obsSdkVersion = OBS_SDK_VERSION;
this.isCname = false;
this.bucketEventEmitters = {};
Expand Down Expand Up @@ -528,7 +528,7 @@ Utils.prototype.refresh = function(ak, sk, securityToken){

Utils.prototype.initFactory = function(ak, sk, isSecure,
server, pathStyle, signature, region, port, maxRetryCount, timeout, sslVerify, longConnection, securityToken,
isSignatureNegotiation, isCname, maxConnections, httpAgent, httpsAgent, userAgent, thirdHttpLib){
isSignatureNegotiation, isCname, maxConnections, httpAgent, httpsAgent, userAgent, thirdHttpLib, noProxyList){

this.refresh(ak, sk, securityToken);

Expand Down Expand Up @@ -624,6 +624,15 @@ Utils.prototype.initFactory = function(ak, sk, isSecure,
this.userAgent = userAgent;
}

if (noProxyList) {
if (typeof noProxyList === 'string') {
this.noProxyList = noProxyList.split(',');
}
if (Array.isArray(noProxyList)) {
this.noProxyList = noProxyList;
}
}

if (thirdHttpLib) {
this.thirdHttpLib = thirdHttpLib;
}
Expand Down Expand Up @@ -1649,6 +1658,18 @@ Utils.prototype.getRequest = function(methodName, serverback, dstFile, saveAsStr

};

function isMatchingPattern(host, pattern) {
const regex = new RegExp(pattern.replace(/\*/g, '.*'), 'i');
return regex.test(host);
}

Utils.prototype.shouldUseProxy = function(requestUrl) {
if (this.noProxyList.length === 0) {
return true
}
return !this.noProxyList.some(pattern => isMatchingPattern(requestUrl, pattern));
}

Utils.prototype.makeRequest = function(methodName, opt, retryCount, bc){
let log = this.log;
let body = opt.xml;
Expand Down Expand Up @@ -1725,12 +1746,14 @@ Utils.prototype.makeRequest = function(methodName, opt, retryCount, bc){
let _isSecure = opt.protocol ? opt.protocol.toLowerCase().indexOf('https') === 0 : this.isSecure;

reopt.agent = _isSecure ? this.httpsAgent : this.httpAgent;
if (!this.shouldUseProxy(reopt.host) && reopt.agent.proxyUri) {
reopt.agent = null;
}

let _http = _isSecure ? httpsLib : httpLib;
if (this.thirdHttpLib) {
_http = this.thirdHttpLib;
}

let req = _http.request(reopt);

if(opt.$requestHook){
Expand Down
37 changes: 36 additions & 1 deletion lib/v2Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,23 @@ const operations = {
'sentAs' : 'meta-',
'withPrefix' : true,
},
'CacheControl': {
'location': 'header',
'sentAs': 'Cache-Control'
},
'ContentDisposition': {
'location': 'header',
'sentAs': 'Content-Disposition',
'encodingSafe': ' ;/?:@&=+$,"'
},
'ContentLanguage': {
'location': 'header',
'sentAs': 'Content-Language'
},
'ContentEncoding': {
'location': 'header',
'sentAs': 'Content-Encoding'
},
'WebsiteRedirectLocation' : {
'location' : 'header',
'sentAs' : 'website-redirect-location',
Expand Down Expand Up @@ -3119,7 +3136,8 @@ const operations = {
},
'ContentDisposition': {
'location': 'header',
'sentAs': 'Content-Disposition'
'sentAs': 'Content-Disposition',
'encodingSafe': ' ;/?:@&=+$,"'
},
'ContentLanguage': {
'location': 'header',
Expand Down Expand Up @@ -3563,6 +3581,23 @@ const operations = {
'sentAs' : 'meta-',
'withPrefix' : true,
},
'CacheControl': {
'location': 'header',
'sentAs': 'Cache-Control'
},
'ContentDisposition': {
'location': 'header',
'sentAs': 'Content-Disposition',
'encodingSafe': ' ;/?:@&=+$,"'
},
'ContentLanguage': {
'location': 'header',
'sentAs': 'Content-Language'
},
'ContentEncoding': {
'location': 'header',
'sentAs': 'Content-Encoding'
},
'WebsiteRedirectLocation' : {
'location' : 'header',
'sentAs' : 'website-redirect-location',
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": "esdk-obs-nodejs",
"version": "3.23.11",
"version": "3.24.3",
"description": "esdk-obs-nodejs",
"engines": {
"node": ">=0.12.7"
Expand Down

0 comments on commit 5cc75e2

Please sign in to comment.