. net web客户端从S3下载2gb后失败



我正在使用web客户端对象来下载一个文件,如下所示:

strm = Client.OpenRead(url);
strm.ReadTimeout = 30000;
bool bFirst = true;
while ((read = strm.Read(buf, 0, 2000)) > 0)
{
    fout.Write(buf, 0, read);
}

url指向S3桶。在某些情况下,下载会在2 GB处超时失败。这是网络问题,还是我可以在代码中更改某些内容?

我相信WebClient会把文件读入内存,你可能会遇到进程大小的限制。

你要使用的是WebClient。DownloadFile

我相信这对你会更好!

最新更新