错误提示:
{"errcode":41005,"errmsg":"media data missing hint: [0363e547]"}
上传方法参考:https://github.com/node-webot...
const request = require('co-request')
const formstream = require('formstream')
const filepath = __dirname + '/123.jpg'
var stat = fs.statSync(filepath);
var form = formstream()
form.file('media', filepath, path.basename(filepath), stat.size);
var url = 'https://api.weixin.qq.com/cgi-bin/media/upload?' + 'access_token=' + access_token + '&type=image'
console.log(url);
var opts = {
method: 'POST',
timeout: 60000, // 60秒超时
headers: form.headers(),
data: form
};
opts.headers.Accept = 'application/json'
const retData = yield request(url, opts)
console.log(retData.body)