develop #10

Merged
s426229 merged 80 commits from develop into master 2021-01-27 18:32:19 +01:00
Showing only changes of commit 7687c54609 - Show all commits

View File

@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Security;
using System.Net;
using System.Linq;
using System.IO;
namespace Klient.Droid
{
@ -20,6 +21,7 @@ namespace Klient.Droid
{
public static int PickImageId = 1000;
private static readonly HttpClient client = new HttpClient();
public static Android.Content.Intent photo;
protected override void OnCreate(Bundle savedInstanceState)
{
@ -136,8 +138,28 @@ namespace Klient.Droid
{
SetContentView(Resource.Layout.ekranPoZdjeciu);
Android.Net.Uri uri = data.Data;
photo = data;
FindViewById<ImageView>(Resource.Id.Preview).SetImageURI(uri);
}
[Java.Interop.Export("SendPhoto")]
async public void UploadPhoto(View v)
{
using(var imageStream = ContentResolver.OpenInputStream(photo.Data))
using(var stramContent = new StreamContent(imageStream))
using(var byteArrayContent = new ByteArrayContent(await stramContent.ReadAsByteArrayAsync()))
using(var formDataContent = new MultipartFormDataContent())
{
formDataContent.Add(byteArrayContent, "file", Guid.NewGuid() + ".jpg");
foreach (var content in formDataContent)
{
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentResolver.GetType(photo.Data));
break;
}
var response = await client.PostAsync("http://10.0.2.2:5001/api/Image/Process", formDataContent);
}
}
}
}