How to use the permalink_public URL of an uploaded image to include it in a message?

眉间皱痕 提交于 2019-12-02 01:51:48

The reason the link for permalink_public does not work in your layout block is that it links to a public website showing the image, but is not a direct link to the image file (which is what you need of course).

But you can construct a direct image link from the link to the website.

The website link you get from permalink_public has the format:

https://slack-files.com/{team_id}-{file_id}-{pub_secret}

The direct link to the image has the format:

https://files.slack.com/files-pri/{team_id}-{file_id}/{filename}?pub_secret={pub_secret}

So you just need to extract the pub_secret from permalink_public and you should be able to construct the direct link to the image. The other parameters you can get from your file object.

Example for your image:

https://files.slack.com/files-pri/T04AG7BVD-FLWHBHY86/no_image_found.png?pub_secret=1ba8263c00

Note that this does no appear to be a documented approach, so as all undocumented approaches and hacks its subject to change.

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