iwillwen / node-qiniu

Qiniu Cloud Storage SDK for Node.js
138 stars 37 forks source link

fetch方法参数url和url模块冲突 #33

Open aofong opened 7 years ago

aofong commented 7 years ago
Asset.prototype.fetch = function(url, callback) {
  var self = this
  return new Promise(function(resolve, reject) {
    callback = callback || noop;

    var path = util.format('/fetch/%s/to/%s', utils.safeEncode(url), self.entryUrl());
    var _url = url.format({
      protocol: 'http',
      hostname: config.vipUrl,
      pathname: path
    });

    var token = self.access_token.token(path, null);

    request({
      url: _url, 
      method: 'POST',
      headers: {
        'Authorization': token,
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }, function(err, res, body) {
      if (err) {
        reject(err);
        return callback(err);
      }

      resolve();
      callback(null);
    });
  })
};
Asset.prototype.fetch = function(url, callback) {
var _url = url.format({ //此处url和参数url有冲突
      protocol: 'http',
      hostname: config.vipUrl,
      pathname: path
    });
}
aofong commented 7 years ago
request({
      url: _url, 
      method: 'POST',
      headers: {
        'Authorization': token,
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }, function(err, res, body) {
      if (err) {
        reject(err);
        return callback(err);
      }

      resolve();
      callback(null); //TODO body参数没有回传
    });
aofong commented 7 years ago
Asset.prototype.token 
Asset.prototype.url //现在的是随机域名,方法要修改了
Fop.prototype.imageView //官方参数已变更imageView=>imageView2