DEV Community

Kazuhiro "Kaz" Sera
Kazuhiro "Kaz" Sera

Posted on

Further Tips on Slack's files.upload Deprecation

As you might already know, the deprecation of Slack's files.upload API and its migration guide to a newer method were announced recently:

https://api.slack.com/changelog/2024-04-a-better-way-to-upload-files-is-here-to-stay

In this article, I'll share some additional tips that you may find useful about the announcement.

So, what exactly sets this new way apart from the prior method? The biggest difference is that, even when your code receives a response from files.completeUploadExternal API endpoint, processing such as security scan is still asynchronously ongoing on the Slack server side. As a result, sharing the uploaded files in a channel could take some time. This behavior change is a compromise intended to resolve the performance issue that the former files.upload API had, particularly with larger files.

This might necessitate some changes to your custom code, especially if you have subsequent operations that rely on a channel message sharing the uploaded files.

If you have such subsequent processing triggered by file share completion, there are two potential approaches:

  1. Regularly poll the files.info API and delay until the file metadata is updated
  2. Respond to the Event API's file_shared event delivery with a different event listener code

Lastly, the v2 method of the official SDKs should function almost seamlessly by just switching the method to call. However, there are still a few differences to keep in mind:

  1. It is now possible to upload several files in one message (yeah, great enhancement!)
  2. The parameter to set the channel to share the files has been changed from channels to channel_id, and you can no longer specify multiple channels or specify a channel by name
  3. As mentioned above, since the new upload process is asynchronous, when having any subsequent processing that needs to occur synchronously, polling the files.info API or utilizing Events API would be required

That's it! I hope you find this article helpful πŸ‘‹

Top comments (0)