The program has a bitmap, which is later saved in .jpg. Then in the format of multipart / form-data is transmitted in a POST request to the server Vk. How to avoid the stage of saving Bitmap and send it directly from the program?
Bitmap image; //Тут его сохраняю //Затем делаю запрос var httpClient = new HttpClient(); var form = new MultipartFormDataContent(); FileStream fs = File.OpenRead(@"C:\Users\Public\Pictures\Sample Pictures\image.jpg"); var streamContent = new StreamContent(fs); var imageContent = new ByteArrayContent(streamContent.ReadAsByteArrayAsync().Result); imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data"); form.Add(imageContent, "file", Path.GetFileName(@"C:\Users\Public\Pictures\Sample Pictures\image.jpg")); var response = httpClient.PostAsync(uploadUrl, form).Result; //и т.д.