Support `deferCommit` in `LargeFileUploadTask` for upload sessions
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- csharp
- Ambito
- api, backend-api-design
Direzione di ricerca
Inizia con src/Microsoft.Graph.Core/Tasks/LargeFileUploadTask.cs, in particolare con UploadAsync, UpdateSessionStatusAsync e il metodo DeleteSessionAsync esistente. Leggi la documentazione collegata di Microsoft Learn sulle sessioni di caricamento e determina come devono essere rappresentati i commit differiti. Il lavoro è completato quando i caricamenti differiti si arrestano dopo l’invio di tutti i byte ed espongono un modo esplicito per completare la sessione senza esaurire i tentativi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C#
- Stelle
- 163
- Fork
- 65
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoftgraph/msgraph-sdk-dotnet-core
-
status:waiting-for-triage type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
status:waiting-for-triage type:bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
microsoftgraph/msgraph-sdk-dotnet-core#1047 · 3 commenti · 8 reazioni ·
-
status:waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
microsoftgraph/msgraph-sdk-dotnet-core#1046 · 2 commenti · 2 reazioni ·
-
.NET
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
Fix CI build on windows-latestForse di nuovo libera @ramsessanchez l’ha presa 304 giorni fa e non c’è nessuna pull request aperta. Aperta
microsoftgraph/msgraph-sdk-dotnet-core#1003 · 1 assegnatario ·
Tutte le issue di microsoftgraph/msgraph-sdk-dotnet-core
Issue simili
-
Backend enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
UI: money shows the minus sign next to the number, not before the currency (IL -3.0m, not -IL 3.0m)Apertaarea: sim area: unity enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eyalgolan/statecraft-israel#1107 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
dimitar-radenkov/Pointframe#271 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
qew21/Genshin-Subtitles#45 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
HoffmanEngineering/3d-print-log-api#274 ·
I maintainer di solito rispondono entro 1 giorno