AttachmentsEx.cs
1 // Code generated by Microsoft (R) AutoRest Code Generator 0.13.0.0
2 // Changes may cause incorrect behavior and will be lost if the code is
3 // regenerated.
4 
5 namespace Microsoft.Bot.Connector
6 {
7  using System;
8  using System.IO;
9  using System.Net.Http;
10  using System.Threading.Tasks;
11 
12  using Microsoft.Rest;
13 
14  public partial class Attachments
15  {
22  public string GetAttachmentUri(string attachmentId, string viewId = "original")
23  {
24  if (attachmentId == null)
25  {
26  throw new ValidationException(ValidationRules.CannotBeNull, "attachmentId");
27  }
28 
29  // Construct URL
30  var _baseUrl = this.Client.BaseUri.AbsoluteUri;
31  var url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "v3/attachments/{attachmentId}/views/{viewId}").ToString();
32  url = url.Replace("{attachmentId}", Uri.EscapeDataString(attachmentId));
33  url = url.Replace("{viewId}", Uri.EscapeDataString(viewId));
34  return url;
35  }
36 
43  public Task<Stream> GetAttachmentStreamAsync(string attachmentId, string viewId = "original")
44  {
45  using (HttpClient client = new HttpClient())
46  {
47  return client.GetStreamAsync(GetAttachmentUri(attachmentId, viewId));
48  }
49  }
50  }
51 }
Task< Stream > GetAttachmentStreamAsync(string attachmentId, string viewId="original")
Get the given attachmentid view as a stream
Attachments operations.
string GetAttachmentUri(string attachmentId, string viewId="original")
Get the URI of an attachment view