Skip to content

Commit

Permalink
fix: host err which old image client request (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiyie committed Sep 29, 2020
1 parent 1f91c3d commit b7b2f1c
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions lib/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@
/* istanbul ignore next */
module.exports = function (OssClient) {
/* istanbul ignore next */
function objectRequestParams(method, name, options) {
options = options || {};
name = this._objectName(name);
const authResource = `/${this.options.bucket}/${name}`;
const params = {
name,
method,
host: this.options.imageHost,
resource: `/${name}`,
timeout: options.timeout,
authResource,
ctx: options.ctx
};

if (options.headers) {
params.headers = options.headers;
}
return params;
}
// function objectRequestParams(method, name, options) {
// options = options || {};
// name = this._objectName(name);
// const authResource = `/${this.options.bucket}/${name}`;
// const params = {
// name,
// method,
// host: this.options.imageHost,
// resource: `/${name}`,
// timeout: options.timeout,
// authResource,
// ctx: options.ctx
// };
// if (options.headers) {
// params.headers = options.headers;
// }
// return params;
// }

function ImageClient(options) {
if (!(this instanceof ImageClient)) {
Expand All @@ -34,9 +33,10 @@ module.exports = function (OssClient) {
throw new Error('require imageHost for image service instance');
}

options.endpoint = options.imageHost;
this.ossClient = new OssClient(options);
this.ossClient.options.imageHost = options.imageHost;
this.ossClient._objectRequestParams = objectRequestParams;
// this.ossClient._objectRequestParams = objectRequestParams;
}

/**
Expand Down Expand Up @@ -124,7 +124,7 @@ module.exports = function (OssClient) {
};

ImageClient.prototype.signatureUrl = function signatureUrl(name) {
return this.ossClient.signatureUrl(name, this.ossClient.options.imageHost);
return this.ossClient.signatureUrl(name);
};

ImageClient.prototype._parseResponse = async function _parseResponse(result) {
Expand Down

0 comments on commit b7b2f1c

Please sign in to comment.