uploadMedia的Shortcut中的uploadImage被后面的同名方法覆盖掉了
charmer1989 opened this issue · comments
['image', 'voice', 'video', 'thumb'].forEach(function (type) {
var method = 'upload' + type[0].toUpperCase() + type.substring(1);
exports[method] = function* (filepath) {
return yield this.uploadMedia(filepath, type);
};
});
这里定义了一个exports.uploadImage
被下面这个方法覆盖了
exports.uploadImage = function* (filepath) {
var token = yield this.ensureAccessToken();
var stat = yield fs.stat(filepath);
var form = formstream();
form.file('media', filepath, path.basename(filepath), stat.size);
var url = this.prefix + 'media/uploadimg?access_token=' + token.accessToken;
var opts = {
method: 'POST',
timeout: 60000, // 60秒超时
headers: form.headers(),
data: form
};
opts.headers.Accept = 'application/json';
return yield this.request(url, opts);
};
fixed by 521eca2