private async void Send(ImageExtension imageExtension) { string extensionImage = ImageExtensionMethods.GetImageExtensionString(imageExtension); try { var upImageBytes = File.ReadAllBytes(imageCompressDirectory + extensionImage); var upJSONBytes = File.ReadAllBytes(JSONFileDirectory); HttpClient client = new HttpClient(); MultipartFormDataContent content = new MultipartFormDataContent(); ByteArrayContent imageContent = new ByteArrayContent(upImageBytes); string imageSendName = "image" + extensionImage; content.Add(imageContent, "image", imageSendName); ByteArrayContent JSONContent = new ByteArrayContent(upJSONBytes); content.Add(JSONContent, "coordinate", "coordinate.txt"); var response = await client.PostAsync(URLSend, content); var responsestr = response.Content.ReadAsStringAsync().Result; } catch (Exception e) { await DisplayAlert("Errore invio file", "Errore connessione con il server " + e.Source, "OK"); } }
/* * Invio file al server in base ad algoritmo scelto */ private void SendFileToServer(CompressionAlgorithmSelected compressionAlgorithmSelected) { ImageExtension imageExtension = ImageExtensionMethods.GetImageExtension(compressionAlgorithmSelected); try { CreateJSONFiles(); Send(imageExtension); } catch (Exception e) { throw new Exception(e.Message); } }