Open angelinashepherd opened 13 hours ago
I am trying to upload a file to Slack and then send a direct message to a user, instead of to a channel. I'm using the node Slack SDK
const { ok, upload_url, file_id } = await slackClient.files.getUploadURLExternal({ filename: fileName, length: fileLength, }); if (!ok || isNil(file_id)) { throw new Error(`Failed to initiate uploading file ${fileName} to Slack channel ${slackChannelId}`); } const response = await axios({ method: methods.POST, url: upload_url, responseType: 'arraybuffer', data: fileContent, }); if (response.status !== StatusCodes.OK) { throw new Error(`Failed to upload file ${fileName} to Slack channel ${slackChannelId}`); } await slackClient.files.completeUploadExternal({ files: [{ id: file_id, title: fileName }], channel_id: 'DXXXXXXXXXXXX', // my own Slack initial_comment: 'file was uploaded successfully!', });
Am I not able to do so?
What kind of token (user or bot) are you using when making the file upload API calls? What error are you seeing?
I am trying to upload a file to Slack and then send a direct message to a user, instead of to a channel. I'm using the node Slack SDK
Am I not able to do so?