+ public async Task PostAsync(Uri uri, IDictionary<string, string> param, IDictionary<string, IMediaItem> media)
+ {
+ var requestUri = new Uri(RestApiBase, uri);
+ var request = new HttpRequestMessage(HttpMethod.Post, requestUri);
+
+ using (var postContent = new MultipartFormDataContent())
+ {
+ if (param != null)
+ {
+ foreach (var (key, value) in param)
+ postContent.Add(new StringContent(value), key);
+ }
+ if (media != null)
+ {
+ foreach (var (key, value) in media)
+ postContent.Add(new StreamContent(value.OpenRead()), key, value.Name);
+ }
+
+ request.Content = postContent;
+
+ try
+ {
+ using (var response = await this.httpUpload.SendAsync(request, HttpCompletionOption.ResponseHeadersRead)
+ .ConfigureAwait(false))
+ {
+ await this.CheckStatusCode(response)
+ .ConfigureAwait(false);
+ }
+ }
+ catch (HttpRequestException ex)
+ {
+ throw TwitterApiException.CreateFromException(ex);
+ }
+ catch (OperationCanceledException ex)
+ {
+ throw TwitterApiException.CreateFromException(ex);
+ }
+ }
+ }
+