【问题标题】:Send Image from byte[] using ms bot, Channel: Facebook, C#使用 ms bot 从 byte[] 发送图像,频道:Facebook,C#
【发布时间】:2020-04-29 01:27:07
【问题描述】:

我需要在机器人中发送图像。将我的图像转换为字节数组。

在模拟器中图像正在发送,但在 Facebook 中,它没有发送。

下面是我的代码。

byte[] imageBytes12 = my image;
string url = "data:image/png;base64," + Convert.ToBase64String(imageBytes12);

var attachmentsImage = new List<Attachment>();
var replyImage = MessageFactory.Attachment(attachmentsImage);
HeroCard menuCardImage = Cards.HeroImageCard(url);
replyImage.Attachments.Add(menuCardImage.ToAttachment());
await stepContext.Context.SendActivityAsync(replyImage, cancellationToken);

见过

当图像转换为字节时,作为 ContentUrl 发送太长,这就是它失败的原因。 任何帮助表示赞赏。

谢谢

【问题讨论】:

  • 听起来您已经知道您的图像太大而无法嵌入。那么你的问题是什么?
  • @Kyle Delanley,我怎么能把它发到 Facebook 上。 Facebook 不接受冗长的网址。
  • 上传文件到某处
  • 嗨@凯尔德兰利,感谢您的回复。我已将图像保存在 blob 中并引用 blob url。感谢您的帮助。

标签: c# facebook botframework chatbot facebook-chatbot


【解决方案1】:

当使用太大而无法作为数据 URL 嵌入的图像时,您需要在服务器上提供指向该图像的链接

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-30
    • 1970-01-01
    • 2017-12-05
    • 2021-06-19
    • 2022-01-05
    • 2021-01-10
    • 2018-06-07
    相关资源
    最近更新 更多