如何发送base64编码的图像? [英] How can I send a base64 encoded image?

查看:107
本文介绍了如何发送base64编码的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过提供已进行base64编码的条形码(.PNG)来响应对话.那可能吗?还是通过网址进行投放的唯一方法.

I would like to respond to a conversation by providing a barcode (.PNG) that has been base64 encoded. Is that possible? Or is the only method of delivery thru a Url.

推荐答案

尝试:

replyMessage.Attachments.Add(new Attachment()
{
     ContentUrl = $"data:image/jpeg;base64,{Convert.ToBase64String(bdata)}"
});

或作为JSON:

{
    "attachments": 
    [
        {
            "contentUrl": $"data:image/jpeg;base64,{Convert.ToBase64String(bdata)}"
        }
    ]
}

其中 bdata 是字节数组

这篇关于如何发送base64编码的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆