Я получаю массив байтов, шестнадцатеричный код после загрузки вложения в Excel в ms chatbot. AttachUrl, которую я получаю, http://localhost:****/v3/attachments/b53bcfb0-81f4-11e9-b7dd-b71944dec1d8/views/original. Теперь, как мне прочитать содержимое в читаемом формате.
публичная виртуальная асинхронная задача MessageReceivedAsync (контекст IDialogContext, аргумент IAwaitable)
{
var message = ожидание аргумента;
if (message.Attachments != null && message.Attachments.Any())
{
var attachment = message.Attachments.First();
using (HttpClient httpClient = new HttpClient())
{
// Skype & MS Teams attachment URLs are secured by a JwtToken, so we need to pass the token from our bot.
if ((message.ChannelId.Equals("skype", StringComparison.InvariantCultureIgnoreCase) || message.ChannelId.Equals("msteams", StringComparison.InvariantCultureIgnoreCase))
&& new Uri(attachment.ContentUrl).Host.EndsWith("skype.com"))
{
var token = await new MicrosoftAppCredentials().GetTokenAsync();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
}
var responseMessage = await httpClient.GetAsync(attachment.ContentUrl);
var contentLenghtBytes = responseMessage.Content.Headers.ContentLength;
await context.PostAsync($"Attachment of {attachment.ContentType} type and size of {contentLenghtBytes} bytes received.");
}
}
else
{
await context.PostAsync("Hi there! I'm a bot created to show you how I can receive message attachments, but no attachment was sent to me. Please, try again sending a new message including an attachment.");
}
context.Wait(this.MessageReceivedAsync);
}
При попытке использовать ExcelReader требуется путь к файлу. Путь к файлу http://localhost:****/v3/attachments/b53bcfb0-81f4-11e9-b7dd-b71944dec1d8/views/original. Я получаю сообщение об ошибке, так как «формат Uri не поддерживается»