0
嘗試通過WebDAM(第三方內容管理系統)API下載大型視頻文件時發生網絡請求超時。以下是用於獲取視頻的基本代碼。網絡請求超時下載大圖像文件
public void StreamAsset(String AssetID, HttpResponse Response)
{
WebRequest request = request = WebRequest.Create(_api_url_v2 + "assets/" + AssetID + "/download");
request.Timeout = 200000;
// add OAuth header
request.Headers.Add("Authorization", "Bearer " + _access_token);
// get response from WebDAM web service
WebResponse response = request.GetResponse();
using (Stream file = response.GetResponseStream())
{
Int32 bytesRead = 0;
Byte[] buffer = new Byte[524000];
while ((bytesRead = file.Read(buffer, 0, buffer.Length)) > 0)
{
if (Response.IsClientConnected)
Response.OutputStream.Write(buffer, 0, bytesRead);
else
break;
}
file.Close();
}
}
}
有沒有更有效的方法來寫這段代碼,或者我只需要插入超時屬性。
我得到了相當標準的下面的錯誤。
堆棧跟蹤: [HttpException(0x80004005的):請求超時]