upload file local to slack api code example
Example: pyhton code to send file to slack
def send_file_to_slack(file_path):
url = "https://slack.com/api/files.upload"
querystring = {"token": xxxxxxx}
payload = {
"channels": xxxxxxxx,
"initial_comment": comment above the file should be here"
}
file_upload = {
"file": (file_path, open(file_path, 'rb'), 'csv')
}
response = requests.post(url, data=payload, params=querystring, files=file_upload)
if response.ok:
return {
"message": "Successfully uploaded the file to slack"
}