I have a requirement for a bot to send a file as a downloadable to the users in Skype. The files are in physical path.
Below is the code:
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}"
};
}
In the above code I am trying to attach the contents of the file in the Message attachment. When I checked the Skype Channel, it displays "MIME type is Invalid"
Note: this is working in the Emulator. I am not using Skype for Business. Also I am aware that this functionality does not work in the Skype for Business.
Also I need to send the location of the file as Hyperlink URL to the user. Currently we were only able to send as String and not as URL. For this functionality we are using Hero Cards.