Can I upload an image as attachment with Slack API?

六眼飞鱼酱① 提交于 2019-11-28 14:26:21

You can not submit a full image as attachments, only URLs to an image.

If you want to upload an image to Slack you can do so by using files.upload. Here is a curl example for uploading a GIF image from the Slack documentation:

curl -F file=@dramacat.gif -F channels=C024BE91L,#general -F token=xxxx-xxxxxxxxx-xxxx https://slack.com/api/files.upload

An alternative is to use an image hoster (e.g. http://imgur.com) to upload and store your image (through their API). Then you can include the image URL in your attachment.

I personally prefer the second option, since its more flexible to include image URLs in messages and images then do not reduce your precious storage space on Slack.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!