【发布时间】:2019-06-25 06:35:01
【问题描述】:
当我尝试调用 slack API 进行上传时,我收到此错误 {"ok":false,"error":"no_file_data"}。我已经在 ./log 中有指定的文件。
robot.respond /upload (.*)/i, (res) ->
app_name = res.match[1]
request = require("request")
fs = require("fs")
channel_name = res.message.room
data = {
channels: channel_name,
filename: "#{app_name}.txt",
file: fs.createReadStream("./log/#{app_name}.txt"),
}
robot.http("https://slack.com/api/files.upload")
.headers(Authorization: 'Bearer slack-token', 'Content-Type': 'application/json')
.post(data) (err, httpRes, body) ->
if err
res.send "#{err}"
return
res.send "#{body}"
【问题讨论】:
-
感谢您添加 Slack 错误。将错误添加到您的第一个问题会更好,但不用担心。请删除您的第一个问题。
标签: coffeescript slack-api hubot