【发布时间】:2018-03-19 12:33:51
【问题描述】:
我正在创建使用本地图像的英雄卡,并且在本地使用模拟器时可以使它们正常工作,但在发布到 azure 后无法正常工作。我正在尝试将图像转换为 base64 以使用它。
List<CardImage> cardImages = new List<CardImage>
{
new CardImage(url: ImageToBase64(thisService.Type.ToString()))
};
(...)
HeroCard plCard = new HeroCard()
{
Title = $"{titles[thisService.Type.ToString()]}",
Subtitle = $"Serviço {thisService.Frequency.ToString()} agendado para {thisService.Date.ToLongDateString()} às {thisService.Date.ToShortTimeString()}.",
Images = cardImages,
Buttons = cardButtons
};
(...)
public static string ImageToBase64(string imageName)
{
var path = HostingEnvironment.MapPath($"/Resources/Images/{imageName}.PNG");
Byte[] bytes = File.ReadAllBytes(path);
string base64String = Convert.ToBase64String(bytes);
return "data:image/png;base64," + base64String;
}
azure 门户频道上出现的错误如下:
{"error":{"message":"(#100) name_placeholder[elements][0][image_url] should represent a valid URL","type":"OAuthException","code":100,"fbtrace_id":"BLoacoRFVy7"}}
这可能吗?
【问题讨论】:
标签: c# file azure url botframework