I have been developing Bot, I have configured my WaterfallDialog, the bot connects to database, get some information and creates Excel file, now I don't know how to upload the file to user. Is it not possible to upload file directly to user?
How to send attachment in bot framework in web embedded bot using c#
I followed the above post, but this provides a URL to the user or it removes the extension from the file Image of file upload to channel without extensions
Edit: I have followed both answers in the above question, the 1st answer uploads the file to the channel, but the file extension and file name is changed. So when user downloads the file they download "original" instead of "file.extension"
As requested, here is the code used.
{
var imagePath = System.Web.HttpContext.Current.Server.MapPath(@"~\Resources\Results.xlsx");
using (var connector = new ConnectorClient(new Uri(serviceUrl)))
{
var attachments = new Attachments(connector);
var response = await attachments.Client.Conversations.UploadAttachmentAsync(
conversationId,
new AttachmentData
{
Name = "Results.xlsx",
OriginalBase64 = File.ReadAllBytes(imagePath),
Type = "text/xlsx"
});
var attachmentUri = attachments.GetAttachmentUri(response.Id);
return new Attachment
{
Name = "Results.xlsx",
ContentType = "text/xlsx",
ContentUrl = attachmentUri
};
}
}