request (options)提交素材的时候报错 source. on is not function
来源:4-8 多媒体与图文素材接口的上传更新获取与删除
Jocker_HimSelf
2018-03-01
options { method: 'POST',
url: 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=7_yTbfOc8CdBRFI0MQfOh73rITawZnKx4tMmTy3Er-96httAkwMqXLbnCTSk-meoqdrIDtbfI7qU6mwYDY4fuVK-hn_cO14vDsy65CSWxoq6ASTHqaFx1e8En3H7eBSof0hE132vTR45qDNJrcXNWfAJANDM&type=video',
json: true,
formData:
ReadStream {
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 65536,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events: { end: [Function] },
_eventsCount: 1,
_maxListeners: undefined,
path: '/Users/jiananlin/ice/violet.mp4',
fd: null,
flags: 'r',
mode: 438,
start: undefined,
end: undefined,
autoClose: true,
pos: undefined,
bytesRead: 0 } }
TypeError: source.on is not a function
at Function.DelayedStream.create (/Users/jiananlin/ice/node_modules/delayed-stream/lib/delayed_stream.js:33:10)
at FormData.CombinedStream.append (/Users/jiananlin/ice/node_modules/combined-stream/lib/combined_stream.js:44:37)
at FormData.append (/Users/jiananlin/ice/node_modules/form-data/lib/form_data.js:74:3)
at appendFormValue (/Users/jiananlin/ice/node_modules/request/request.js:323:21)
at Request.init (/Users/jiananlin/ice/node_modules/request/request.js:334:11)
at Request.RP$initInterceptor [as init] (/Users/jiananlin/ice/node_modules/request-promise-core/configure/request2.js:45:29)
at new Request (/Users/jiananlin/ice/node_modules/request/request.js:128:8)
at request (/Users/jiananlin/ice/node_modules/request/index.js:53:10)
at /Users/jiananlin/ice/server/wechat-lib/index.js:70:30
at Generator.next (<anonymous>)
at step (/Users/jiananlin/ice/server/wechat-lib/index.js:17:191)
at /Users/jiananlin/ice/server/wechat-lib/index.js:17:437
at new Promise (<anonymous>)
at /Users/jiananlin/ice/server/wechat-lib/index.js:17:99
at wechat.request (/Users/jiananlin/ice/server/wechat-lib/index.js:67:26)
at /Users/jiananlin/ice/server/wechat-lib/index.js:101:29
at Generator.next (<anonymous>)
at step (/Users/jiananlin/ice/server/wechat-lib/index.js:17:191)
at /Users/jiananlin/ice/server/wechat-lib/index.js:17:361
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
2回答
-
Jocker_HimSelf
提问者
2018-03-01
原来之前是我formdata 直接用流文件上传了,看微信文档需要在formdata 里面给流文件加上media标:formdata:{media:流文件},这样就不用加filename了
10 -
Jocker_HimSelf
提问者
2018-03-01
let options = { method: 'POST', url: myurl, headers: { 'header1': myheader}, formData: { file: { value: fs.createReadStream(path), options: { fileName: req.fileName} } }}; request(options,callback)
加了fileName 就可以了
00
相似问题