Can I upload an image as attachment with Slack API?

前端 未结 1 2040
夕颜
夕颜 2020-12-04 03:36

I have integrated Slack API using cURL in my project.
I want to send an image as my attachment. It works while sending full image path in image_url. But whe

相关标签:
1条回答
  • 2020-12-04 04:14

    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.

    0 讨论(0)
提交回复
热议问题