예제 #1
0
        internal static async Task <string> PostImageStream(byte[] input)
        {
            try
            {
                Stream stream = new MemoryStream(input);
                using (HttpClient client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Constants.BaseURL);
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Constants.AuthorizationHeaderType, await Logic.GetToken());
                    StreamContent       inputData = new StreamContent(stream);
                    string              urlLink   = "chat/postimage";
                    HttpResponseMessage response  = await client.PostAsync(urlLink, inputData).ConfigureAwait(false);

                    var result = await response.Content.ReadAsStringAsync();

                    return(result);
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex, Logic.GetErrorProperties(ex));
                return(string.Empty);
            }
        }