private async void UploadSinglePhotoToWall(object sender, EventArgs e) { var photo = GetPhoto(); var request = VKApi.UploadWallPhotoRequest(new VKUploadImage(photo, VKImageParameters.JpgImage(0.9f)), 0, OwnerId); try { var response = await request.ExecuteAsync(); RecycleBitmap(photo); var photoModel = ((VKPhotoArray)response.ParsedModel) [0]; MakePost("Photos from Xamarin.Android!", new VKAttachments(photoModel)); } catch (VKException ex) { ShowError(ex.Error); } }
private async void UploadMultiplePhotosToWall(object sender, EventArgs e) { var photo = GetPhoto(); var request1 = VKApi.UploadWallPhotoRequest(new VKUploadImage(photo, VKImageParameters.JpgImage(0.9f)), 0, OwnerId); var request2 = VKApi.UploadWallPhotoRequest(new VKUploadImage(photo, VKImageParameters.JpgImage(0.5f)), 0, OwnerId); var request3 = VKApi.UploadWallPhotoRequest(new VKUploadImage(photo, VKImageParameters.JpgImage(0.1f)), 0, OwnerId); var request4 = VKApi.UploadWallPhotoRequest(new VKUploadImage(photo, VKImageParameters.PngImage()), 0, OwnerId); var batch = new VKBatchRequest(request1, request2, request3, request4); var responses = await batch.ExecuteAsync(); try { RecycleBitmap(photo); var resp = responses.Select(r => ((VKPhotoArray)r.ParsedModel) [0]); var attachments = new VKAttachments(); attachments.AddRange(resp); MakePost("I just uploaded multiple files from the VK Xamarin.Android SDK!", attachments); } catch (VKException ex) { ShowError(ex.Error); } }