Skip to content

Instantly share code, notes, and snippets.

@nodoid
Created January 20, 2016 15:05
Show Gist options
  • Save nodoid/303be439be4177840e57 to your computer and use it in GitHub Desktop.
Save nodoid/303be439be4177840e57 to your computer and use it in GitHub Desktop.
IMediaPicker media;
btnTakePic.Clicked += async delegate
{
try
{
progressStack.IsVisible = progressStack.IsEnabled = true;
App.Self.Uploaded = 0;
var mediaFile = await media.TakePhotoAsync(new CameraMediaStorageOptions { DefaultCamera = CameraDevice.Front, MaxPixelDimension = 400 });
Device.BeginInvokeOnMainThread(async () =>
await DisplayAlert("Uploading", "Your photo is currently being uploaded to our servers. This may take some time depending on your connection speed", "OK").ContinueWith(async w =>
{
if (w.IsCompleted)
{
filesize = (int)mediaFile.Source.Length;
DependencyService.Get<INetwork>().NetworkSpinner(true);
await SendData.HttpPost(mediaFile, App.Self.Settings.GetSetting<string>("token"), userProfile.xACCid, folderid);
}
}));
}
catch (Exception)
{
}
};
btnUpload.Clicked += async delegate
{
try
{
progressStack.IsVisible = progressStack.IsEnabled = true;
App.Self.Uploaded = 0;
var mediaFile = await media.SelectPhotoAsync(new CameraMediaStorageOptions
{
DefaultCamera = CameraDevice.Rear,
MaxPixelDimension = 400
});
Device.BeginInvokeOnMainThread(async () =>
await DisplayAlert("Uploading", "Your photo is currently being uploaded to our servers. This may take some time depending on your connection speed", "OK").ContinueWith(async w =>
{
if (w.IsCompleted)
{
DependencyService.Get<INetwork>().NetworkSpinner(true);
filesize = (int)mediaFile.Source.Length;
await SendData.HttpPost(mediaFile, App.Self.Settings.GetSetting<string>("token"), userProfile.xACCid, folderid);
}
}));
}
catch (Exception)
{
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment