Support `deferCommit` in `LargeFileUploadTask` for upload sessions
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- api, backend-api-design
Hướng nghiên cứu
Bắt đầu với src/Microsoft.Graph.Core/Tasks/LargeFileUploadTask.cs, đặc biệt là UploadAsync, UpdateSessionStatusAsync và phương thức DeleteSessionAsync hiện có. Đọc tài liệu Microsoft Learn được liên kết về phiên tải lên và xác định cách biểu diễn các commit bị trì hoãn. Công việc được hoàn thành khi các lượt tải lên bị trì hoãn dừng lại sau khi đã gửi tất cả byte và cung cấp một cách rõ ràng để hoàn tất phiên mà không làm cạn kiệt số lần thử lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 163
- Fork
- 65
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoftgraph/msgraph-sdk-dotnet-core
-
status:waiting-for-triage type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
status:waiting-for-triage type:bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
microsoftgraph/msgraph-sdk-dotnet-core#1047 · 3 bình luận · 8 reaction ·
-
status:waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
microsoftgraph/msgraph-sdk-dotnet-core#1046 · 2 bình luận · 2 reaction ·
-
.NET
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Fix CI build on windows-latestCó thể làm lại được @ramsessanchez đã nhận 307 ngày trước và không có pull request nào đang mở. Đang mở
microsoftgraph/msgraph-sdk-dotnet-core#1003 · 1 người được giao ·
Tất cả issue của microsoftgraph/msgraph-sdk-dotnet-core
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug priority: P2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
IridiumIO/CompactGUI#699 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
bitfoundation/bitplatform#14070 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày