【发布时间】:2018-12-03 07:47:24
【问题描述】:
Bot Builder SDK 4 (dotnet) 如何处理附件?我尝试使用 BotBuilder-Samples 15.handling-attachments 的示例,但 Skype 频道出现 401 Unauthorized 错误。
foreach (var file in activity.Attachments)
{
// Determine where the file is hosted.
var remoteFileUrl = file.ContentUrl;
// Save the attachment to the system temp directory.
var localFileName = Path.Combine(Path.GetTempPath(), file.Name)
// Download the actual attachment
using (var webClient = new WebClient())
{
webClient.DownloadFile(remoteFileUrl, localFileName); <-- 401 here
}
【问题讨论】:
-
你到底想做什么?上传附件还是下载?
-
Bot 用户上传附件(一些文本文件),我需要阅读和处理它
-
看起来您无权将文件保存到该目录,也许尝试另一个目录或尝试将文件保存到 azure storage 之类的地方。
-
只有Skype频道有问题,webchat没有错误,所以问题不在本地路径
-
看看当您使用图像(png、jpeg 等)而不是文本文件时会发生什么。 Skype 对允许您使用的文件类型很挑剔。
标签: c# .net botframework