As per the answer above you need to handle that through the API call: to files.upload
But the test API keys have been deprecated and cannot be generated anymore.
To get the Key you need to:
- Go to Your Apps in Slack API documentation.
- Create a new app.
- Go to the app and go to OAuth & Permissions section
- There you will find Bot User OAuth Token. It should start with
xoxb-...
For posting the files you need to add files:write
permission to the Bot Token Scopes section. Note that if you do that on existing bot, when changing the scope the bot needs to be reinstalled in channels.
Once that's configured you can try your connection:
curl -F [email protected] -F "initial_comment=Shakes the cat" -F channels=C024BE91L -H "Authorization: Bearer xoxb-xxxxxxxxx-xxxx" https://slack.com/api/files.upload
You can find the channel ID in Slack in Channel details.