Beispiel #1
0
        private async void UploadButton_Click(object sender, RoutedEventArgs e)
        {
            if (_currentUser.CurrentlyQueuedFile == null)
            {
                var messageDialog = new MessageDialog("You need to drop an image first.");

                await messageDialog.ShowAsync();

                return;
            }

            var sfToBytes = await FileToByteConverter.Instance.ConvertFileToByte(_currentUser.CurrentlyQueuedFile);

            var imageEndpoint = new ImageEndpoint(_currentUser.ApiClient, _currentUser.HttpClient);

            var response = await imageEndpoint.UploadImageAsBytesAsync(sfToBytes, "test", "description");

            if (response?.Title != null)
            {
                var successUpload = new ContentDialog()
                {
                    Title             = "The upload was successful",
                    Content           = response.Link,
                    PrimaryButtonText = "Ok"
                };

                await successUpload.ShowAsync();
            }
            else
            {
                var failedUpload = new ContentDialog()
                {
                    Title             = "The upload failed",
                    PrimaryButtonText = "Ok"
                };

                await failedUpload.ShowAsync();
            }
        }