How can I send a base64 encoded image?

爷,独闯天下 提交于 2021-01-28 19:31:15

问题


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.


回答1:


Try:

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

Or as JSON:

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

Where bdata is a byte array



来源:https://stackoverflow.com/questions/37574157/how-can-i-send-a-base64-encoded-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!