I'm looking for documentation for how to upload a file. I see that support was added in v4.0.0 for uploading files, but am unsure how to use this feature.
x in one of the [ ])x in each of the [ ])I realized that I must contact the robot.adapter.client.web.files.upload method. Ticket can be closed.
Example:
opts = {
content: body
channels: res.message.room
}
robot.adapter.client.web.files.upload('filename.ext', opts)
@juilianoj can you please post a example of your full request to upload the file? I'm stuck trying to do the same.
@sergioagg Here's a full sample script for you. This listens for a message of 'testslackfileupload' followed by the name of the file you want to send to slack. You can obviously set the file name within the script rather than passing it in through the message if you want.
# Description:
# contains listener that will upload file to slack
#
# Commands:
# hubot testslackfileupload <filename> - uploads file to slack with the filename passed in
#
# Author:
# juilianoj
module.exports = (robot) ->
robot.respond /testslackfileupload (.*)/i, (res) ->
filename = res.match[1]
opts = {
content: 'the content of your file'
title: 'Your Test File Title As Displayed In Slack'
channels: res.message.room
}
robot.adapter.client.web.files.upload(filename, opts)
The result looks like this, and when you download the file it would have the file name you passed in:

@juilianoj awesome! that's exactly what I was looking for, really appreciated.
Most helpful comment
@sergioagg Here's a full sample script for you. This listens for a message of 'testslackfileupload' followed by the name of the file you want to send to slack. You can obviously set the file name within the script rather than passing it in through the message if you want.
The result looks like this, and when you download the file it would have the file name you passed in: