Support `deferCommit` in `LargeFileUploadTask` for upload sessions
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- csharp
调研方向
从 src/Microsoft.Graph.Core/Tasks/LargeFileUploadTask.cs 开始,重点查看 UploadAsync、UpdateSessionStatusAsync 和现有的 DeleteSessionAsync 方法。阅读链接的 Microsoft Learn 上传会话文档,并确定应如何表示延迟提交。当延迟上传在发送完所有字节后停止,并提供一种无需耗尽重试次数即可显式完成会话的方式时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
I want to defer the final creation of the file being uploaded via an upload session in the destination (in this case, SharePoint Embedded) until I explicitly make a request to complete the upload. For this, I'm setting the deferCommit property in the request arguments for the creation of the upload session, as indicated in Create an upload session - driveItem: createUploadSession | MS Learn.
When using LargeFileUploadTask to use the created upload session, as indicated in Upload large files using the Microsoft Graph SDKs | MS Learn, the upload task does not stop when all the bytes have been uploaded and the server returns that there are no nextExpectedRanges in the 202 response. It starts a loop to retrieve the status of the upload session and the expected ranges (which in return are empty) until all retry attempts have been exhausted. Then, it throws an exception saying Upload failed too many times..
From source: LargeFileUploadTask.cs
public async Task<UploadResult<T>> UploadAsync(IProgress<long> progress = null, int maxTries = 3, CancellationToken cancellationToken = default)
{
var uploadTries = 0;
var trackedExceptions = new List<Exception>();
while (uploadTries < maxTries)
{
var sliceRequests = this.GetUploadSliceRequests();
foreach (var request in sliceRequests)
{
var uploadResult = await this.UploadSliceAsync(request, trackedExceptions, cancellationToken).ConfigureAwait(false);
progress?.Report(request.RangeEnd);//report the progress of upload (how many bytes have been uploaded so far)
if (uploadResult.UploadSucceeded) // **<--- from observation/testing: this is always false**
{
return uploadResult;
}
ThrowIfUploadCancelled(trackedExceptions, cancellationToken);
}
await this.UpdateSessionStatusAsync(cancellationToken).ConfigureAwait(false);
uploadTries += 1;
if (uploadTries < maxTries)
{
// Exponential back off in case of failures.
await Task.Delay(2000 * uploadTries * uploadTries, cancellationToken).ConfigureAwait(false);
}
ThrowIfUploadCancelled(trackedExceptions, cancellationToken);
}
throw new TaskCanceledException("Upload failed too many times. See InnerException for list of exceptions that occured.", new AggregateException(trackedExceptions.ToArray()));
}
public async Task<IUploadSession> UpdateSessionStatusAsync(CancellationToken cancellationToken = default)
{
var requestBuilder = new UploadSessionRequestBuilder(this.Session, this._requestAdapter);
var newSession = await requestBuilder.GetAsync(cancellationToken).ConfigureAwait(false);
var newRangesRemaining = this.GetRangesRemaining(newSession); // **<--- from observation/testing: this return empty**
this._rangesRemaining = newRangesRemaining;
newSession.UploadUrl = this.Session.UploadUrl; // Sometimes the UploadUrl is not returned
this.Session = newSession;
return newSession;
}
Proposed solution
I would like LargeFileUploadTask to handle defer commits. Alternatives:
- Allow the caller to indicate that the upload is deferred during construction (i.e.: a parameter).
- The task itself can interpret the 202 response with no next expected ranges as having the commit deferred.
Once the task is done uploading, there could be a CommitSessionAsync method (in the same line as the DeleteSessionAsync method) to perform the commit request.
- 主要语言
- C#
- 星标
- 163
- 派生
- 65
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoftgraph/msgraph-sdk-dotnet-core 的其他 Issue
-
status:waiting-for-triage type:bug
难度 2/5 1-3 小时 新手友好度 68/100
-
status:waiting-for-triage type:bug
难度 3/5 1-2 天 新手友好度 55/100
microsoftgraph/msgraph-sdk-dotnet-core#1047 · 3 条评论 · 8 个 reaction ·
-
status:waiting-for-triage
难度 2/5 1-3 小时 新手友好度 45/100
microsoftgraph/msgraph-sdk-dotnet-core#1046 · 2 条评论 · 2 个 reaction ·
-
.NET
难度 4/5 3-5 天 新手友好度 25/100
-
Fix CI build on windows-latest可能重新可做 @ramsessanchez 于 306 天前认领,目前没有进行中的 PR。 未关闭
microsoftgraph/msgraph-sdk-dotnet-core#1003 · 已指派 1 人 ·
查看 microsoftgraph/msgraph-sdk-dotnet-core 的全部 Issue
相似的 Issue
-
/api/oauth/introspect emits clientId and tokenType instead of RFC 7662's client_id and token_type未关闭bug P2
难度 2/5 1-3 小时 新手友好度 78/100
nightscout/nocturne#2317 ·
维护者通常 1 天内回复
-
[BUG]: Position intent set on a simple order is dropped when it becomes a bracket, OCO or OTO order可能已有人在做 @RaphaelFakhri 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
alpacahq/alpaca-trade-api-csharp#903 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
joinrpg/joinrpg-net#5752 ·
维护者通常 1 天内回复
-
bug ux
难度 2/5 1-3 小时 新手友好度 78/100
CodeForFire/lagebuch#714 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
dimitar-radenkov/Pointframe#294 ·
维护者通常 1 天内回复