MS-Graph-Sdk-DotNet:上传大文件时如何同时发送多个块请求?

MS-Graph-Sdk-DotNet: How to send multiple chunk requests at the same time when uploading a large file?

创建上传会话后,我正在通过发送块请求上传一个大文件的内容。但是,一次发送一个请求需要较长的时间来上传文件的全部内容。

是否可以使用多线程同时发送多个块请求?

我试过使用 Parallel.ForEach,但它不起作用。

int maxSizeChunk = 320 * 1024 * 4;
ChunkedUploadProvider uploadProvider = new ChunkedUploadProvider(uploadSession, client, ms, maxSizeChunk);
IEnumerable<UploadChunkRequest> chunkRequests = uploadProvider.GetUploadChunkRequests();
List<Exception> exceptions = new List<Exception>();
byte[] readBuffer = new byte[maxSizeChunk];

//  How to send multiple requests at once?
foreach (UploadChunkRequest request in chunkRequests)
{
     UploadChunkResult result = await uploadProvider.GetChunkRequestResponseAsync(request, readBuffer, exceptions);

     if (result.UploadSucceeded)
         uploadedFile = result.ItemResponse;
}

我认为您不能同时通过多个流上传。

根据 documentation:

The fragments of the file must be uploaded sequentially in order. Uploading fragments out of order will result in an error.