Skip to content

Commit

Permalink
支持自定义 Protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Mar 14, 2018
1 parent ee1626e commit 1bedb79
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ var defaultOptions = {
ProgressInterval: 1000,
Domain: '',
ServiceDomain: '',
SliceSize: 1024 * 1024 * 20
SliceSize: 1024 * 1024 * 20,
Protocol: ''
};

// 对外暴露的类
Expand Down Expand Up @@ -2577,6 +2578,7 @@ function putObject(params, callback) {
}
if (data && data.headers && data.headers['etag']) {
var url = getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
Expand Down Expand Up @@ -3041,6 +3043,7 @@ function multipartComplete(params, callback) {
return callback(err);
}
var url = getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
Expand Down Expand Up @@ -3230,6 +3233,7 @@ function getAuth(params) {
function getObjectUrl(params, callback) {
var self = this;
var url = getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
Expand Down Expand Up @@ -3315,7 +3319,7 @@ function getUrl(params) {
var region = params.region;
var object = params.object;
var action = params.action;
var protocol = util.isBrowser && location.protocol === 'http:' ? 'http:' : 'https:';
var protocol = params.protocol || (util.isBrowser && location.protocol === 'http:' ? 'http:' : 'https:');
if (!domain) {
if (['cn-south', 'cn-south-2', 'cn-north', 'cn-east', 'cn-southwest', 'sg'].indexOf(region) > -1) {
domain = '{{Bucket}}-{{AppId}}.{{Region}}.myqcloud.com';
Expand Down Expand Up @@ -3442,6 +3446,7 @@ function _submitRequest(params, callback) {

var opt = {
url: url || getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: bucket,
region: region,
Expand Down
2 changes: 1 addition & 1 deletion dist/cos-js-sdk-v5.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,7 @@ function putObject(params, callback) {
}
if (data && data.headers && data.headers['etag']) {
var url = getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
Expand Down Expand Up @@ -1428,6 +1429,7 @@ function multipartComplete(params, callback) {
return callback(err);
}
var url = getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
Expand Down Expand Up @@ -1618,6 +1620,7 @@ function getAuth(params) {
function getObjectUrl(params, callback) {
var self = this;
var url = getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
Expand Down Expand Up @@ -1704,7 +1707,7 @@ function getUrl(params) {
var region = params.region;
var object = params.object;
var action = params.action;
var protocol = util.isBrowser && location.protocol === 'http:' ? 'http:' : 'https:';
var protocol = params.protocol || (util.isBrowser && location.protocol === 'http:' ? 'http:' : 'https:');
if (!domain) {
if (['cn-south', 'cn-south-2', 'cn-north', 'cn-east', 'cn-southwest', 'sg'].indexOf(region) > -1) {
domain = '{{Bucket}}-{{AppId}}.{{Region}}.myqcloud.com';
Expand Down Expand Up @@ -1829,6 +1832,7 @@ function _submitRequest(params, callback) {

var opt = {
url: url || getUrl({
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: bucket,
region: region,
Expand Down
1 change: 1 addition & 0 deletions src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var defaultOptions = {
Domain: '',
ServiceDomain: '',
SliceSize: 1024 * 1024 * 20,
Protocol: '',
};

// 对外暴露的类
Expand Down

0 comments on commit 1bedb79

Please sign in to comment.