【发布时间】:2017-06-09 07:18:13
【问题描述】:
我正在尝试使用以下 Microsoft Graph 调用从 OneDrive 下载文件:
using (var strm = await client.Drives[RemoteDriveId].Items[Id].Content.Request().GetAsync())
{
byte[] byteBuffer = new byte[4096];
filePath = System.IO.Path.Combine(folderPath, filename);
using (System.IO.FileStream output = new FileStream(filePath, FileMode.Create))
{
int bytesRead = 0;
do
{
bytesRead = contentStream.Read(byteBuffer, 0, byteBuffer.Length);
if (bytesRead > 0)
{
output.Write(byteBuffer, 0, bytesRead);
}
}
while (bytesRead > 0);
}
}
上面代码的问题是,如果文件很大或者网络很慢,在文件完全下载之前SDK中就会抛出请求超时异常。我想分块下载文件或增加超时。如何使用 Microsoft graph SDK 实现这一点?
【问题讨论】:
标签: office365 microsoft-graph-api onedrive