Closed charmer1989 closed 7 years ago
['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 521eca25e1ceee1c93ed6d171d46650c894b2bd7
这里定义了一个exports.uploadImage 被下面这个方法覆盖了