使用fs.createReadStream

时间:2018-01-11 00:17:18

标签: node.js fs slack-api

以下代码:

const Slack = require('slack');
const fs = require('fs');

const token = 'super-secret-token-my-brah';
const slack = new Slack({ token });

slack.files.upload({
    channel: 'general',
    file: fs.createReadStream(__dirname + '/test.jpg'),
})
.then(console.log)
.catch(console.error);

给我以下错误:

Error: no_file_data
    at _res (/Users/myname/Desktop/repos/myapp/node_modules/slack/src/_exec.js:56:17)
    at IncomingMessage.__end (/Users/myname/Desktop/repos/myapp/node_modules/tiny-json-http/_write.js:75:9)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1056:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

文件出现在给定的路径上,所以这不是问题。我一直在搜索Slack文档和所有内容,但没有任何线索。

任何人都知道这里发生了什么?

0 个答案:

没有答案