Since the slack file.upload is going to be depreciated, I was going to make new the methods work.
The first one works as:
curl -s -F [email protected] -F filename=test.txt -F token=xoxp-token -F length=50123 https://slack.com/api/files.getUploadURLExternal
and returns
{"ok":true,"upload_url":"https://files.slack.com/upload/v1/CwABAAAAXAoAAVnX....","file_id":"F07XXQ9XXXX"}
The second request is:
curl -X POST -H "Authorization: Bearer xoxp-token"
-H "Content-Type: application/json"
-d '{
"files": [{"id":"F07XXXXXX", "title":"Slack API updates Testing"}],
"channel_id": "C06EXXXXX"
}'
https://slack.com/api/files.completeUploadExternal
With the second request, I get 200 OK responses.
{"ok":true,"files":[{"id":"XXXXXXX","created":XXXXXXXX,"timestamp":XXXXXXXX,"name":"test.txt","title":"Slack API updates Testing","mimetype":"","filetype":"","pretty_type":"","user":"XXXXXXXXX","user_team":"XXXXXXXXX","editable":false,"size":50123,"mode":"hosted","is_external":false,"external_type":"","is_public":false,"public_url_shared":false,"display_as_bot":false,"username":"","url_private":"https://files.slack.com/files-pri/XXXXXXXXX-XXXXXXX/test.txt","url_private_download":"https://files.slack.com/files-pri/XXXXXXXXX-XXXXXXX/download/test.txt","media_display_type":"unknown","permalink":"https://XXXXXXXX.slack.com/files/XXXXXXXXX/XXXXXXX/test.txt","permalink_public":"https://slack-files.com/XXXXXXXXX-XXXXXXX-XXXXXXXX","comments_count":0,"is_starred":false,"shares":{},"channels":[],"groups":[],"ims":[],"has_more_shares":false,"has_rich_preview":false,"file_access":"visible"}],"warning":"missing_charset","response_metadata":{"warnings":["missing_charset"]}}
Questions and problems:
1- How do I determine the length= in the first request (files.getUploadURLExternal
)
2- Even though I have provided the channel_id the file is still not getting uploaded on the Slack channel.