如何发送base64编码的PDF文件? [英] How do I send a base64 encoded PDF file?

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

问题描述

我希望我的机器人将PDF文件发送给用户.我将PDF作为base64字符串,并尝试通过附件发送它:

I want my bot to send a PDF file to the user. I have the PDF as a base64 string and tried to send it through an attachment:

Attachment attachment1 = new Attachment();
attachment1.Name = "name.pdf";
attachment1.ContentType = "application/pdf";
attachment1.ContentUrl = "data:application/pdf;base64," + base64String;

var m = context.MakeMessage();
m.Attachments.Add(attachment1);
m.Text = "File";

await context.PostAsync(m);

在模拟器中,它只是不起作用,但是在Telegram和Facebook(我需要)频道中,该机器人只是输出了一个错误...

Within the emulator, it just doesn't work but in the channels Telegram and Facebook (which I need), the bot just outputs an error...

有人已经成功了吗?

注意:使用HTTP地址可以正常工作,但我需要使用base64字符串

Note: Using an HTTP address works fine, but I need to use the base64 string

推荐答案

在botframework中,此方法调用Telegram的sendDocument方法,并且该方法在其document属性中获取http url或file_id,因此您可以t将base64String作为有效的文档类型传递给此方法.

As this method in botframework call sendDocument method of Telegram, and this method in its document property get http url or a file_id, so you can't pass base64String to this method as a valid document type.

您可以在此链接(另请参见下图).

You can follow the valid type of the document passing into the telegram in this link (also, see the following image).

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

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