diff options
author | marcinzelent <marcin@zelent.net> | 2017-05-27 15:09:52 +0200 |
---|---|---|
committer | marcinzelent <marcin@zelent.net> | 2017-05-27 15:09:52 +0200 |
commit | e3de8bc1a60a0c538b989ce8ee0873ee9af55a56 (patch) | |
tree | 45235a45d7488f2dc96d6e72baa41076b89b1aa7 | |
parent | 44065455f5e237164e15cda9894be2d3399fad9a (diff) |
Fixed NullReferenceException when user didn't pick photo.
-rw-r--r-- | ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs | 12 |
1 files 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 |