node-webot / co-wechat-api

Wechat API. Support Async Functions
Other
724 stars 170 forks source link

请问上传临时素材使用buffer上传为何一直提示错误 #110

Closed mani95lisa closed 5 years ago

mani95lisa commented 5 years ago
const result = await this.ctx.curl(picUrl, { streaming: true });
    const stream = result.res;
    const bufs = [];
    let buf = null;
    const read = new Promise((resolve, reject) => {
      stream.on('data', chunk => {
        bufs.push(chunk);
      });
      stream.on('end', () => {
        buf = Buffer.concat(bufs);
        console.log('end');
        resolve(buf);
      });
      stream.on('error', () => {
        reject();
      });
    });
    const r = await read;
return await api.uploadMedia(r, 'image', 'image/jpg', 'image/jpg');

一直提示 {"errcode":40005,"errmsg":"invalid file type hint: [TPYgvA00951538]"} 就是获取了一个临时的二维码,然后打算推送消息给到用户,不知道这种用法具体错在哪里呢,多谢。

mani95lisa commented 5 years ago

使用文件地址是没任何问题的