Open xuwenliu opened 3 years ago
上传了文件了才会返回media_id呀,你这个逻辑搞错了。
上传了文件了才会返回media_id呀,你这个逻辑搞错了。
不是media_id,可查看我写的注释 我的意思是: 你这里导出了4个快捷方法。那调用这4个快捷方法时,如果filepath是传递的buffer,那么就缺失了filename这个参数。
if (Buffer.isBuffer(filepath)) {
form.buffer('media', filepath, filename, mime); // 需要filename这个参数
}
['image', 'voice', 'video', 'thumb'].forEach(function (type) {
var method = 'upload' + type[0].toUpperCase() + type.substring(1);
var newMethod = method + 'Media';
exports[method] = util.deprecate(async function (filepath) {
return this.uploadMedia(filepath, type);
}, `${method}: Use ${newMethod} instead`);
exports[newMethod] = async function (filepath) { // 未接受filename参数
return this.uploadMedia(filepath, type); // 调用uploadMedia方法
};
});
``
uploadImageMedia(filepath) uploadVoiceMedia(filepath) uploadVideoMedia(filepath) uploadThumbMedia(filepath)
以上4个快捷方法少了filename参数
看了源码: