From e3de8bc1a60a0c538b989ce8ee0873ee9af55a56 Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 27 May 2017 15:09:52 +0200 Subject: Fixed NullReferenceException when user didn't pick photo. --- .../ApartmentManager/Persistency/ImgurPhotoUploader.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs b/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs index 7e9ebf2..ed0041e 100644 --- a/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs +++ b/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs @@ -39,10 +39,14 @@ namespace ApartmentManager.Persistency StorageFile file = await fp.PickSingleFileAsync(); //Upload to Imgur and return link - var client = new ImgurClient("7b05a61ed8df74f", "ade6f79163e19f92f852bc553bbe399d7d4218fe"); - var endpoint = new ImageEndpoint(client); - IImage image = await endpoint.UploadImageStreamAsync(await file.OpenStreamForReadAsync()); - return image.Link; + if (file != null) + { + var client = new ImgurClient("7b05a61ed8df74f", "ade6f79163e19f92f852bc553bbe399d7d4218fe"); + var endpoint = new ImageEndpoint(client); + IImage image = await endpoint.UploadImageStreamAsync(await file.OpenStreamForReadAsync()); + return image.Link; + } + else return ""; } } } \ No newline at end of file -- cgit v1.2.3