如何在Adaptive Card中使用图片w/o直接URL到图片
How to use image in Adaptive Card w/o direct URL to the image
我想在自适应卡片中使用来自 MS Graph 的用户个人资料图片。我已经确定我需要进行的 API 调用如下
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/profilephoto_get
在这种情况下,我会将图像作为个人资料照片的二进制数据获取,需要将其转换为 base-64 字符串。
但是,基于 adaptive cards schema document 看起来我们应该使用 URL 属性 其中值应该直接 URL 到图像
'url string Yes The URL to the image'
我应该如何处理这个问题?如果有任何方法可以在 Adaptive Card w/o 中使用图像直接 URL 到图像??
您可以使用 data URI to encode the bytes directly into the payload. Something like this sample:
var photo = await client.Me.Photos[size].Content.Request().GetAsync();
var photoStream = new MemoryStream();
photo.CopyTo(photoStream);
var photoBytes = photoStream.ToArray();
return string.Format("data:image/png;base64,{0}",
Convert.ToBase64String(photoBytes));
我想在自适应卡片中使用来自 MS Graph 的用户个人资料图片。我已经确定我需要进行的 API 调用如下
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/profilephoto_get
在这种情况下,我会将图像作为个人资料照片的二进制数据获取,需要将其转换为 base-64 字符串。
但是,基于 adaptive cards schema document 看起来我们应该使用 URL 属性 其中值应该直接 URL 到图像
'url string Yes The URL to the image'
我应该如何处理这个问题?如果有任何方法可以在 Adaptive Card w/o 中使用图像直接 URL 到图像??
您可以使用 data URI to encode the bytes directly into the payload. Something like this sample:
var photo = await client.Me.Photos[size].Content.Request().GetAsync();
var photoStream = new MemoryStream();
photo.CopyTo(photoStream);
var photoBytes = photoStream.ToArray();
return string.Format("data:image/png;base64,{0}",
Convert.ToBase64String(photoBytes));