public static async Task <Message> SendPhotoAsync(this Telegram telegram, SendPhotoRequest sendRequest, string file = null) { var result = new Message(); if (string.IsNullOrEmpty(file) && string.IsNullOrEmpty(sendRequest.Photo)) { return(null); } var url = telegram.GetFullPathUrl("sendPhoto"); using (var form = new MultipartFormDataContent()) { AddParametersToRequest(form, sendRequest); using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read)) { if (!string.IsNullOrEmpty(file)) { form.Add(new StreamContent(fileStream), "photo", Path.GetFileName(file)); } using (var client = new HttpClient()) { var responseHendler = await client.PostAsync(url, form); if (responseHendler != null) { var response = await responseHendler.Content.ReadAsStringAsync(); if (!string.IsNullOrEmpty(response)) { result = Newtonsoft.Json.JsonConvert.DeserializeObject <ResponseAnswer <Message> >(response).Result; } } } } } return(result); }
public SendPhotoResponse SendPhoto(SendPhotoRequest sendPhotoRequest) { Log.Info(nameof(SendPhoto)); return(SendPhotoResponse.Parse(ExecuteAction(sendPhotoRequest))); }
public SendPhotoResponse SendPhoto(SendPhotoRequest sendPhotoRequest) { return(SendPhotoResponse.Parse(ExecuteAction(sendPhotoRequest))); }
public SendPhotoResponse SendPhoto(SendPhotoRequest sendPhotoRequest) { return SendPhotoResponse.Parse(ExecuteAction(sendPhotoRequest)); }