【发布时间】:2018-01-04 11:29:57
【问题描述】:
我将我的文件上传到 azure 数据湖中。我尝试通过 asp.net mvc 应用程序下载该文件。我有该文件的 adl 路径。我可以下载低于 150 MB 的文件。但我无法下载超过 150 MB 的文件。出现超时错误。
下面是我的代码...
public ActionResult Download(string adlpath)
{
String header = adlpath;
Console.WriteLine(header);
string[] splitedStr = header.Split('/');
var path = GenerateDownloadPaths(adlpath);
string filename = path["fileName"];
HttpResponseMessage val = DataDownloadFile(path["fileSrcPath"]);
byte[] filedata = val.Content.ReadAsByteArrayAsync().Result;
string contentType = MimeMapping.GetMimeMapping(filename);
var cd = new System.Net.Mime.ContentDisposition
{
FileName = filename,
Inline = true,
};
Response.AppendHeader("Content-Disposition", cd.ToString());
return File(filedata, contentType);
}
public HttpResponseMessage DataDownloadFile(string srcFilePath)
{
string DownloadUrl = "https://{0}.azuredatalakestore.net/webhdfs/v1/{1}?op=OPEN&read=true";
var fullurl = string.Format(DownloadUrl, _datalakeAccountName, srcFilePath);
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesstoken.access_token);
using (var formData = new MultipartFormDataContent())
{
resp = client.GetAsync(fullurl).Result;
}
}
return resp;
}
【问题讨论】:
-
请添加具体错误,因为文本不是屏幕打印。
-
在本地我可以下载 135 MB 的文件。我在 azure 中托管我的应用程序,我尝试下载。在那里下载 1 KB 文件。
-
不回答您的问题,但您应该考虑不要按照 ASP.NET Web API 文档中的Create and Initialize HttpClient 部分中的说明对每个请求创建新的
HttpClient。
标签: c# asp.net-mvc azure azure-data-lake