<commit_before>﻿namespace SelfHostedYoloScreenCapture
{
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Net;
    using System.Net.Http;

    public class PhotoUploader
    {
        private readonly string _serverPath;

        public PhotoUploader(string serverPath)
        {
            _serverPath = serverPath;
        }

        public void Upload(Image capturedSelection)
        {
            using (var client = new HttpClient())
            {
                var stream = new MemoryStream();
                capturedSelection.Save(stream, ImageFormat.Jpeg);
                var streamContent = new ByteArrayContent(stream.ToArray());
                streamContent.Headers.Add("Content-Type", "image/jpeg");

                var multipartFormDataContent = new MultipartFormDataContent();
                multipartFormDataContent.Add(streamContent, "upload", "tmp.jpg");

                var requestMessage = new HttpRequestMessage(HttpMethod.Post, _serverPath);
                requestMessage.Content = multipartFormDataContent;

                var httpResponseMessage = client.SendAsync(requestMessage).Result;

                var result = httpResponseMessage.Content.ReadAsStringAsync().Result;
                Console.WriteLine(result);
            }
        }
    }
}<commit_msg>reading json response from server<commit_after>﻿namespace SelfHostedYoloScreenCapture
{
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Net;
    using System.Net.Http;
    using Newtonsoft.Json;

    public class PhotoUploader
    {
        private readonly string _serverPath;

        public PhotoUploader(string serverPath)
        {
            _serverPath = serverPath;
        }

        public void Upload(Image capturedSelection)
        {
            using (var client = new HttpClient())
            {
                var stream = new MemoryStream();
                capturedSelection.Save(stream, ImageFormat.Jpeg);
                var streamContent = new ByteArrayContent(stream.ToArray());
                streamContent.Headers.Add("Content-Type", "image/jpeg");

                var multipartFormDataContent = new MultipartFormDataContent();
                multipartFormDataContent.Add(streamContent, "upload", "tmp.jpg");

                var requestMessage = new HttpRequestMessage(HttpMethod.Post, _serverPath);
                requestMessage.Content = multipartFormDataContent;

                var httpResponseMessage = client.SendAsync(requestMessage).Result;

                var resultString = httpResponseMessage.Content.ReadAsStringAsync().Result;

                var resultObject = JsonConvert.DeserializeObject<ServerResult>(resultString);

                Console.WriteLine(resultObject.ImagePath);
            }
        }

        class ServerResult
        {
            public string ImagePath { get; set; }
        }
    }
}
{'fraction_non_alphanumeric': 0.07833947104117844, 'fraction_numerical': 0.0, 'mean_word_length': 2.1452631578947368, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3423663', 'n_tokens_mistral': 741, 'n_tokens_neox': 698, 'n_words': 152}