@@ -2991,12 +2991,13 @@ function getAuth(params) {
2991
2991
*/
2992
2992
function getObjectUrl ( params , callback ) {
2993
2993
var self = this ;
2994
+ var useAccelerate = params . UseAccelerate === undefined ? self . options . UseAccelerate : params . UseAccelerate ;
2994
2995
var url = getUrl ( {
2995
2996
ForcePathStyle : self . options . ForcePathStyle ,
2996
2997
protocol : params . Protocol || self . options . Protocol ,
2997
2998
domain : params . Domain || self . options . Domain ,
2998
2999
bucket : params . Bucket ,
2999
- region : params . Region ,
3000
+ region : useAccelerate ? 'accelerate' : params . Region ,
3000
3001
object : params . Key ,
3001
3002
} ) ;
3002
3003
@@ -3016,7 +3017,7 @@ function getObjectUrl(params, callback) {
3016
3017
}
3017
3018
3018
3019
// 签名加上 Host,避免跨桶访问
3019
- var SignHost = getSignHost . call ( this , { Bucket : params . Bucket , Region : params . Region , Url : url } ) ;
3020
+ var SignHost = getSignHost . call ( this , { Bucket : params . Bucket , Region : params . Region , UseAccelerate : params . UseAccelerate , Url : url } ) ;
3020
3021
var AuthData = getAuthorizationAsync . call ( this , {
3021
3022
Action : ( ( params . Method || '' ) . toUpperCase ( ) === 'PUT' ? 'name/cos:PutObject' : 'name/cos:GetObject' ) ,
3022
3023
Bucket : params . Bucket || '' ,
@@ -3185,12 +3186,13 @@ function getUrl(params) {
3185
3186
3186
3187
var getSignHost = function ( opt ) {
3187
3188
if ( ! opt . Bucket || ! opt . Region ) return '' ;
3189
+ var useAccelerate = opt . UseAccelerate === undefined ? this . options . UseAccelerate : opt . UseAccelerate ;
3188
3190
var url = opt . Url || getUrl ( {
3189
3191
ForcePathStyle : this . options . ForcePathStyle ,
3190
3192
protocol : this . options . Protocol ,
3191
3193
domain : this . options . Domain ,
3192
3194
bucket : opt . Bucket ,
3193
- region : this . options . UseAccelerate ? 'accelerate' : opt . Region ,
3195
+ region : useAccelerate ? 'accelerate' : opt . Region ,
3194
3196
} ) ;
3195
3197
var urlHost = url . replace ( / ^ h t t p s ? : \/ \/ ( [ ^ / ] + ) ( \/ .* ) ? $ / , '$1' ) ;
3196
3198
var standardHostReg = new RegExp ( '^([a-z\\d-]+-\\d+\\.)?(cos|cosv6|ci|pic)\\.([a-z\\d-]+)\\.myqcloud\\.com$' ) ;
0 commit comments