Mar*_*arn 9 microsoft-cognitive botframework skype-bots
我正在使用带有Cognitive Services的Microsoft Bot Framework从用户通过bot上传的源图像生成图像.我正在使用C#.
Cognitive Services API返回一个byte[]或Stream表示处理过的图像.
如何将该图像直接发送给我的用户?所有的文档和示例似乎都指向我必须将图像托管为可公开寻址的URL并发送链接.我可以这样做,但我宁愿不这样做.
有谁知道如何简单地返回图像,有点像Caption Bot吗?
小智 9
你应该可以使用这样的东西:
var message = activity.CreateReply("");
message.Type = "message";
message.Attachments = new List<Attachment>();
var webClient = new WebClient();
byte[] imageBytes = webClient.DownloadData("https://placeholdit.imgix.net/~text?txtsize=35&txt=image-data&w=120&h=120");
string url = "data:image/png;base64," + Convert.ToBase64String(imageBytes)
message.Attachments.Add(new Attachment { ContentUrl = url, ContentType = "image/png" });
await _client.Conversations.ReplyToActivityAsync(message);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2267 次 |
| 最近记录: |