files.upload 使用 Slack 的 Node SDK 时出现问题
Issue with files.upload using Slack's Node SDK
我正在尝试通过 Slack SDK 上传文件,但遇到了问题。目前我通过以下代码取得了成功:
const res = await client.files.upload({
channel: 'CHANNEL',
file: Buffer.from('hello'),
filename: 'test.txt',
filetype: 'text/plain',
});
响应类似于:
{ ok: true,
file:
{ id: 'FIDTM4IDM',
created: 1568847491,
timestamp: 1568847491,
name: 'test.txt',
title: 'test',
mimetype: 'text/plain',
filetype: 'text',
pretty_type: 'Plain Text',
...
...
}
}
然而,当我查看时,频道中没有显示任何内容。我知道事情配置正确,因为我可以 post 使用相同配置向频道发送消息。
您 属性 拼错了。它被称为 channels
而不是 channel
。因此 API 将忽略您的频道 属性 并且文件会上传到 Slack,但不会在频道中共享。
还要确保仅使用频道 ID。不支持频道名称。
我正在尝试通过 Slack SDK 上传文件,但遇到了问题。目前我通过以下代码取得了成功:
const res = await client.files.upload({
channel: 'CHANNEL',
file: Buffer.from('hello'),
filename: 'test.txt',
filetype: 'text/plain',
});
响应类似于:
{ ok: true,
file:
{ id: 'FIDTM4IDM',
created: 1568847491,
timestamp: 1568847491,
name: 'test.txt',
title: 'test',
mimetype: 'text/plain',
filetype: 'text',
pretty_type: 'Plain Text',
...
...
}
}
然而,当我查看时,频道中没有显示任何内容。我知道事情配置正确,因为我可以 post 使用相同配置向频道发送消息。
您 属性 拼错了。它被称为 channels
而不是 channel
。因此 API 将忽略您的频道 属性 并且文件会上传到 Slack,但不会在频道中共享。
还要确保仅使用频道 ID。不支持频道名称。