Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9cb0023

Browse files
committed
update source image domain and add tests
1 parent5ca13ec commit9cb0023

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- 对象存储,修复无法对 key 为空字符串的对象进行操作
44
- 对象存储,查询区域域名支持配置 UC 地址
55
- 对象存储,查询区域域名接口升级
6+
- 对象存储,更新设置镜像源的域名
67

78
##7.8.0
89
- 移除不推荐域名,并增加 亚太-首尔 和 华东-浙江2 固定区域

‎qiniu/storage/rs.js‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -373,19 +373,21 @@ function changeTypeReq(mac, config, bucket, key, newType, callbackFunc) {
373373
);
374374
}
375375

376-
// 设置空间镜像源
377-
//@link https://developer.qiniu.com/kodo/api/1370/mirror
378-
//@param bucket 空间名称
379-
//@param srcSiteUrl 镜像源地址
380-
//@param srcHost 镜像Host
381-
//@param callbackFunc(err, respBody, respInfo) 回调函数
382-
constPU_HOST='http://pu.qbox.me:10200';
376+
/**
377+
* 设置空间镜像源
378+
*@link https://developer.qiniu.com/kodo/3966/bucket-image-source
379+
*@param {string} bucket 空间名称
380+
*@param {string} srcSiteUrl 镜像源地址
381+
*@param {string} srcHost 镜像Host
382+
*@param {function(err: error, respBody: object, respInfo: object)} callbackFunc 回调函数
383+
*/
383384
BucketManager.prototype.image=function(bucket,srcSiteUrl,srcHost,
384385
callbackFunc){
385-
varencodedSrcSite=util.urlsafeBase64Encode(srcSiteUrl);
386-
varrequestURI=PU_HOST+'/image/'+bucket+'/from/'+encodedSrcSite;
386+
constencodedSrcSite=util.urlsafeBase64Encode(srcSiteUrl);
387+
constscheme=this.config.useHttpsDomain ?'https://' :'http://';
388+
letrequestURI=scheme+conf.UC_HOST+'/image/'+bucket+'/from/'+encodedSrcSite;
387389
if(srcHost){
388-
varencodedHost=util.urlsafeBase64Encode(srcHost);
390+
constencodedHost=util.urlsafeBase64Encode(srcHost);
389391
requestURI+='/host/'+encodedHost;
390392
}
391393
rpc.postWithOptions(
@@ -398,13 +400,15 @@ BucketManager.prototype.image = function (bucket, srcSiteUrl, srcHost,
398400
);
399401
};
400402

401-
// 取消设置空间镜像源
402-
//@link https://developer.qiniu.com/kodo/api/1370/mirror
403-
//@param bucket 空间名称
404-
//@param callbackFunc(err, respBody, respInfo) 回调函数
403+
/**
404+
* 取消设置空间镜像源
405+
*@param {string} bucket 空间名称
406+
*@param {function(err: error, respBody: object, respInfo: object)} callbackFunc 回调函数
407+
*/
405408
BucketManager.prototype.unimage=function(bucket,callbackFunc){
406-
varrequestURI=PU_HOST+'/unimage/'+bucket;
407-
vardigest=util.generateAccessTokenV2(this.mac,requestURI,'POST','application/x-www-form-urlencoded');
409+
constscheme=this.config.useHttpsDomain ?'https://' :'http://';
410+
constrequestURI=scheme+conf.UC_HOST+'/unimage/'+bucket;
411+
constdigest=util.generateAccessTokenV2(this.mac,requestURI,'POST','application/x-www-form-urlencoded');
408412
rpc.postWithoutForm(requestURI,digest,callbackFunc);
409413
};
410414

‎test/rs.test.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,4 +901,30 @@ describe('test start bucket manager', function () {
901901
});
902902
});
903903
});
904+
905+
describe('test bucket image source',function(){
906+
it('test set image',function(done){
907+
bucketManager.image(
908+
srcBucket,
909+
'http://devtools.qiniu.com/',
910+
'devtools.qiniu.com',
911+
function(err,respBody,respInfo){
912+
should.not.exist(err,JSON.stringify(respInfo));
913+
respInfo.statusCode.should.be.eql(200,JSON.stringify(respInfo));
914+
done();
915+
}
916+
);
917+
});
918+
919+
it('test unset image',function(done){
920+
bucketManager.unimage(
921+
srcBucket,
922+
function(err,respBody,respInfo){
923+
should.not.exist(err,JSON.stringify(respInfo));
924+
respInfo.statusCode.should.be.eql(200,JSON.stringify(respInfo));
925+
done();
926+
}
927+
);
928+
});
929+
});
904930
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp