1

The following code:

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);

Is giving me the following 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)

The file is present at the path given, so that's not the problem. I've been searching through the Slack documentation and everything, but no leads.

Anyone have any idea what's happening here?

TVG
  • 259
  • 3
  • 8
  • My guess it that your class can not work with a stream as input for the file. But its impossible to help you without knowing how the those classes (e.g. Slack) are defined. Please post which library you are using or post the relevant custom classes. – Erik Kalkoken Jan 11 '18 at 17:56

0 Answers0