0

我需要机器人将文件作为可下载文件发送给 Skype 中的用户。文件在物理路径中。

下面是代码:

public async Task SelectedOptionAsync(IDialogContext context, IAwaitable<string> argument) 
{ 
 var message = await argument; 
 var replyMessage = context.MakeMessage(); 
 Attachment attachment = null; 
 attachment = GetLocalAttachment(); 
 replyMessage.Attachments = new List<Attachment> { attachment }; 
 await context.PostAsync(replyMessage); 
 await this.DisplayOptionsAsync(context); 
} 

private static Attachment GetLocalAttachment() 
{ 
 var Path = HttpContext.Current.Server.MapPath("~/images/demo.pdf"); 
 var pdfdata = Convert.ToBase64String(File.ReadAllBytes(Path)); 
 return new Attachment 
 { 
 Name = "demo.pdf", 
 ContentType = "application/pdf", 
 ContentUrl = $"data:application/pdf;base64,{pdfdata}" 
 }; 
}

在上面的代码中,我试图在消息附件中附加文件的内容。当我检查 Skype 频道时,它显示“MIME 类型无效”

注意:这是在模拟器中工作的。我没有使用 Skype for Business。我也知道此功能在 Skype for Business 中不起作用。

我还需要将文件的位置作为超链接 URL 发送给用户。目前我们只能作为字符串而不是 URL 发送。对于这个功能,我们使用英雄卡。

4

1 回答 1

1

Sending PDFs like this is not supported by skype bots at this time. I ran into this issue as well and this is the response I got from the Skype team. "Bots in Skype can send only media attachments (video, audio) due to security concerns with sending potentially dangerous files."

for your follow up question have you tried markdown? [text](https://example.com)?

于 2018-03-07T17:37:25.307 回答