C# 无法使用directline在Webchat中发送附件,相同的代码在emulator中工作正常
上面的代码在webchat中抛出下面的异常,当我尝试向用户发送附件时,在emulator中它工作正常 在 Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessageAsync(字符串 会话ID、字符串activityId、活动活动、字典`2 中的CustomHeader、CancellationToken和CancellationToken) D:\a\1\s\libraries\Microsoft.Bot.Connector\Conversations.cs:第1121行 在 Microsoft.Bot.Connector.ConversationsExtensions.ReplyToActivityAsync(IConversations 操作,字符串会话ID,字符串活动ID,活动 中的活动,取消令牌(取消令牌) D:\a\1\s\libraries\Microsoft.Bot.Connector\ConversationsExtensions.cs:line 241 在 Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync(iTunesContext turnContext,活动[]活动,取消令牌 取消令牌)在 D:\a\1\s\libraries\Microsoft.Bot.Builder\BotFrameworkAdapter.cs:line 316 在 Microsoft.Bot.Builder.TurnContext.c__DisplayClass22_0.d.MoveNext() 在D:\a\1\s\libraries\Microsoft.Bot.Builder\TurnContext.cs中:第267行 我甚至试过这个C# 无法使用directline在Webchat中发送附件,相同的代码在emulator中工作正常,c#,.net-core,botframework,direct-line-botframework,C#,.net Core,Botframework,Direct Line Botframework,上面的代码在webchat中抛出下面的异常,当我尝试向用户发送附件时,在emulator中它工作正常 在 Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessageAsync(字符串 会话ID、字符串activityId、活动活动、字典`2 中的CustomHeader、CancellationToken和CancellationToken) D:\a\1\s\libraries\Microsoft.Bot.Conne
var response = MessageFactory.Attachment(new Attachment
{
Name = @"application.png",
ContentType = "image/png",
ContentUrl = "base64sting"
});
await dc.Context.SendActivityAsync(response);
这也是失败的,是否有任何解决方法可以在没有托管内容url的情况下使用webchat向用户发送附件?对于面临此问题的用户,下面是根本原因
我试图将图像作为一个项目发送以单击并保存,我想我已经解决了问题,directline仅支持4MB的消息大小,我图像的base64string非常大,导致消息超过4MB,现在正在将图像上载到azure blob并将blob uri用作contentURI,它现在正在工作您的详细信息中缺少异常的名称/详细信息,您刚刚添加了路径您是要发送要显示的图像文件还是作为要单击、保存、下载的项目?@StevenKanberg我试图将图像作为要单击和保存的项目发送,我想我已经解决了问题,directline只支持4MB的消息大小,我的图像的base64string非常大,导致消息超过4MB,现在我正在将图像上载到azure blob,并将blob uri用作contentURI,它正在工作
using (var connector = new ConnectorClient(new Uri(serviceUrl)))
{
var attachments = new Attachments(connector);
var response = await attachments.Client.Conversations.UploadAttachmentAsync(
conversationId,
new AttachmentData
{
Name = @"Resources\architecture-resize.png",
OriginalBase64 = File.ReadAllBytes(imagePath),
Type = "image/png",
}
);
var attachmentUri = attachments.GetAttachmentUri(response.Id);
return new Attachment
{
Name = @"Resources\architecture-resize.png",
ContentType = "image/png",
ContentUrl = attachmentUri,
};
}