Skip to content

Commit

Permalink
Added null check !!
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Nov 29, 2019
1 parent 18e4624 commit c8306ff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion XamarinFileUploader.iOS/FileUploaderHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ private void Update(string identifier, NSError error)
var urlKey = identifier;

var r = FileUploaderService.Instance.Requests.FirstOrDefault(x => x.Identifier == identifier);
if (r == null)
{
return;
}
if (error != null)
{
r.ResponseCode = 500;
Expand Down Expand Up @@ -72,7 +76,8 @@ public override void DidReceiveData(NSUrlSession session, NSUrlSessionDataTask d
string key = session.Configuration.Identifier;

var r = FileUploaderService.Instance.Requests.FirstOrDefault(x => x.Identifier == session.Configuration.Identifier);

if (r == null)
return;
var bytes = data.ToArray();
using (var s = System.IO.File.OpenWrite(r.ResponseFilePath))
{
Expand All @@ -86,6 +91,10 @@ public override void DidSendBodyData(NSUrlSession session, NSUrlSessionTask task
string urlKey = session.Configuration.Identifier;

var r = FileUploaderService.Instance.Requests.FirstOrDefault(x => x.Identifier == session.Configuration.Identifier);
if (r == null)
{
return;
}
r.TotalBytes = (int)totalBytesExpectedToSend;
r.TotalSent = (int)totalBytesSent;

Expand Down

0 comments on commit c8306ff

Please sign in to comment.