首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法通过团队外发webhook将附件(图像等)发送到Send服务

无法通过团队外发webhook将附件(图像等)发送到Send服务
EN

Stack Overflow用户
提问于 2020-07-01 16:03:16
回答 1查看 390关注 0票数 2

我在团队中使用一个外发的webhook来发送文本以及附件/图像到自定义的well服务。我正在获取get服务中的文本消息数据,但当从团队发送时,我无法获取图像数据或任何附件(外发webhook)

是否支持?如果没有任何解决方法?

EN

回答 1

Stack Overflow用户

发布于 2020-07-07 14:46:20

实际的卡片JSON附件不会发送到webhook。这类似于bot场景。

对于图像,如果用户附加了一个图像,它将被Bot后端解析并转换为img标签,这应该在内容中作为HTML在一个附件对象中可用。图像本身存储在AMS (团队后端存储)中,源URL也将表示AMS URL,而不是原始URL。用户发送的示例图片:

代码语言:javascript
复制
img height=\"142\" src=\"https://us-api.asm.skype.com/v1/objects/0-eus-d1-abe032166f0b806fe9cb17411e42678f/views/imgo\" width=\"336\" id=\"x_0-eus-d1-abe032166f0b806fe9cb17411e42678f\" itemscope=\"\" itemtype=\"http://schema.skype.com/AMSImage\" style=\"vertical-align:bottom; width:336px; height:142px\">

您应该能够使用MicrosoftAppCredential下载该映像。示例代码:

代码语言:javascript
复制
using (HttpClient httpClient = new HttpClient())
            {
                // MS Teams attachment URLs are secured by a JwtToken, so we need to pass the token from our bot.
                var token = await new MicrosoftAppCredentials("id", "password").GetTokenAsync();
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                var responseMessage = await httpClient.GetAsync(imageUrl);
                var contentLenghtBytes = responseMessage.Content.Headers.ContentLength;
                // You could not use this response message to fetch the image for further processing.

                if (responseMessage.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    Stream attachmentStream = await responseMessage.Content.ReadAsStreamAsync();
                    attachmentStream.Position = 0;
                    System.Drawing.Image image = System.Drawing.Image.FromStream(attachmentStream);
                    image.Save(@"ImageFromUser.png");
                }
            }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62672295

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档