python-slack-sdk: Uploaded files are not appearing in channel and do not contain mimetype
I am trying to upload a file to a private Slack channel using the Slack API via the following Python script. However, once uploaded, the file cannot be downloaded by users in the channel. I am looking for help to understand why this is happening and how to resolve it.
Python runtime version
3.12.1
I used these step:
- https://slack.com/api/files.getUploadURLExternal
- https://slack.com/api/files.completeUploadExternal
- https://slack.com/api/files.sharedPublicURL
Actual result:
{
"ok": true,
"file": {
"id": "XXXXXXXXXX",
"created": 1729848820,
"timestamp": 1729848820,
"name": "xxxxxxxxxxxxxxxxxx.xxx",
"title": "xxxxxxxxxxxxxxxxxxxx.xxx",
"mimetype": "",
"filetype": "",
"pretty_type": "",
"user": "XXXXXXXXX",
"user_team": "XXXXXXXX",
"editable": false,
"size": 61652577,
"mode": "hosted",
"is_external": false,
"external_type": "",
"is_public": false,
"public_url_shared": true,
"display_as_bot": false,
"username": "",
"url_private": "https://files.slack.com/files-pri/xxxxxxxxx-xxxxxxxxxx/xxxxxxxxxxxxxxxxxx.xxx",
"url_private_download": "https://files.slack.com/files-pri/xxxxxxxxxxxxx-xxxxxxx/download/xxxxxxxxxxxxxxxxxx.xxx",
"media_display_type": "unknown",
"permalink": "https://xxxxxxxxx.slack.com/files/xxxxxxxxxx/xxxxxxxxxxxxxxx/xxxxxxxxxxxxx.xxx",
"permalink_public": "https://slack-files.com/xxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxx",
"comments_count": 0,
"is_starred": false,
"shares": {},
"channels": [],
"groups": [],
"ims": [],
"has_more_shares": false,
"has_rich_preview": false,
"file_access": "visible"
}
}
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (3 by maintainers)
I’m also having the same problem, but with the JavaScript SDK
EDIT: My issue was I let AI edit the code and it changed the HTTP POST request uploading the data to a PUT request which is incorrect, the API returns an OK response but it’s not OK. I assumed the AI knew what it was doing when it did that and forgot all about it. Hours later and spying on the connection after being given a working workflow by Slack, I was able to ascertain the issue. The API unhelpfully returns an OK response to PUT but it’s not OK!
Eggs on my face really though.
bumping this because i’m having the same issue. when calling
files.completeUploadExternaland passing eitherchannel_idorchannels, the file does not get shared with the channel. there are no errors. and checkingfiles.infoconfirms the file was properly uploaded just not shared. I believe this is a bug in the slack api and not the python sdk since I have reproduced this behavior with the slack api tester, curl, and the ruby sdk. it’s sdk agnostic.The cause of your confusion may not be related to this, but the
files.completeUploadExternalAPI processes its tasks asynchronously. This means that if a subsequent operation attempts to download the uploaded file immediately, it might fail until thefiles.completeUploadExternaloperation completes. It appears that your code is trying to download the files right away. In most cases, this can fail regardless of whether the files are public or private.One way to determine if the upload operation is finished is to check if the “shares” property is available in the file’s metadata. You can verify this by polling the
files.infoAPI with the uploaded file’s ID.