You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Other: fileBox.toFile raise exception 'uncaughtException Error: The stream is not readable. Maybe has already been consumed, and now it was drained. See: https://github.com/huan/file-box/issues/50'
#239
Closed
timewalker08 opened this issue
Aug 10, 2023
· 3 comments
Please make sure you have read the Wechaty Puppet Service from Wechaty Official Website before you continue writting this issue.
Question
I am trying to save image if wechat receive an image.
Following is my code:
async function onMessage(msg: Message) {
if (msg.type() === bot.Message.Type.Image) {
const fileBox = await msg.toFileBox();
const fileName = `${fileBox.name}.png`;
await fileBox.toFile(fileName, true);
console.log(`Image has been downloaded as ${fileName}`);
}
}
The code didn't read the stream, however, it raise error:
uncaughtException Error: The stream is not readable. Maybe has already been consumed, and now it was drained. See: huan/file-box#50 at FileBox.toStream (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:796:17) at FileBox.pipe (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:1020:10) at /Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:926:12 at new Promise () at FileBox.toFile (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:921:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async WechatyImpl.onMessage (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/src/wechat-bot.ts:47:9)
Please make sure you have read the Wechaty Puppet Service from Wechaty Official Website before you continue writting this issue.
Question
I am trying to save image if wechat receive an image.
Following is my code:
The code didn't read the stream, however, it raise error:
Source code is here: https://github.com/timewalker08/wechaty-test
The text was updated successfully, but these errors were encountered: