var response = MessageFactory.Attachment(new Attachment
{
Name = @"application.png",
ContentType = "image/png",
ContentUrl = "base64sting"
});
await dc.Context.SendActivityAsync(response);
Above code throwing the below exception in webchat when i try to send attachment to user , in emulator it is working fine
at Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessagesAsync(String conversationId, String activityId, Activity activity, Dictionary`2 customHeaders, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Connector\Conversations.cs:line 1121
at Microsoft.Bot.Connector.ConversationsExtensions.ReplyToActivityAsync(IConversations operations, String conversationId, String activityId, Activity activity, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Connector\ConversationsExtensions.cs:line 241
at Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder\BotFrameworkAdapter.cs:line 316
at Microsoft.Bot.Builder.TurnContext.<>c__DisplayClass22_0.d.MoveNext() in D:\a\1\s\libraries\Microsoft.Bot.Builder\TurnContext.cs:line 267
I even tried this
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,
};
}
this is failing as well, is there any work around to send attachment to user using webchat without having hosted content url?
For those who are facing this issue , below is the root cause.
I was trying to send image as an item to click and save, i think i figured out the issue, directline supports only 4MB message size, the base64string of my image is very large , causing the message to exceed 4MB, now am uploading the image to azure blob and using the blob uri as contentURI , it is working now