public async Task<bool> LoadAttachmentFromServer()
{
bool retVal = false;
if (String.IsNullOrWhiteSpace(this.RemoteURL))
{
throw new Exception("Attachment not found! Did you upload your attachment to the server?");
}
var request = WebRequest.CreateHttp(new Uri(this.RemoteURL, UriKind.Absolute));
request.Method = "Get";
request.SetHeader(HttpRequestHeader.UserAgent.ToString(), HockeyClient.Current.AsInternal().UserAgentString);
try
{
var response = await request.GetResponseAsync();
var ms = new MemoryStream();
response.GetResponseStream().CopyTo(ms);
this.DataBytes = ms.ToArray();
retVal = true;
}
catch (Exception e)
{
var webex = e as WebException;
if (webex != null)
{
if (String.IsNullOrWhiteSpace(webex.Response.ContentType))
{
//Connection error during call
throw webex;
}
else
{
//404 Response from server => thread got deleted
retVal = false;
}
}
else
{
throw;
}
}
return retVal;
}
}