microsoftgraph / microsoftgraph/msgraph-sdk-java

LargeFileUpload problem if 1 byte left from last slice

Offen
#2,581 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

status:waiting-for-triage type:bug
Vorherrschende Sprache
Java
Sterne
444
Forks
154
Ø Merge
18 Std. 28 Min.
Gemergte PRs (30 T.)
4

Beschreibung

Describe the bug

Hello,
i have a problem to upload files if exactly 1 byte is missing in the last slice.

The upload is throwing an exception:
java.util.concurrent.CancellationException: The upload task was retried the maximum number of times without success and has been cancelled.

E.g.
Filesize: 288001

Slice: 32000
Uploaded 32000 bytes of 288001 total bytes
Uploaded 64000 bytes of 288001 total bytes
Uploaded 96000 bytes of 288001 total bytes
Uploaded 128000 bytes of 288001 total bytes
Uploaded 160000 bytes of 288001 total bytes
Uploaded 192000 bytes of 288001 total bytes
Uploaded 224000 bytes of 288001 total bytes
Uploaded 256000 bytes of 288001 total bytes
Uploaded 288000 bytes of 288001 total bytes
-> last one missing

Slice: 16000
Uploaded 16000 bytes of 288001 total bytes
Uploaded 32000 bytes of 288001 total bytes
Uploaded 48000 bytes of 288001 total bytes
Uploaded 64000 bytes of 288001 total bytes
Uploaded 80000 bytes of 288001 total bytes
Uploaded 96000 bytes of 288001 total bytes
Uploaded 112000 bytes of 288001 total bytes
Uploaded 128000 bytes of 288001 total bytes
Uploaded 144000 bytes of 288001 total bytes
Uploaded 160000 bytes of 288001 total bytes
Uploaded 176000 bytes of 288001 total bytes
Uploaded 192000 bytes of 288001 total bytes
Uploaded 208000 bytes of 288001 total bytes
Uploaded 224000 bytes of 288001 total bytes
Uploaded 240000 bytes of 288001 total bytes
Uploaded 256000 bytes of 288001 total bytes
Uploaded 272000 bytes of 288001 total bytes
Uploaded 288000 bytes of 288001 total bytes
-> last one missing

Slice: 64000
Uploaded 64000 bytes of 288001 total bytes
Uploaded 128000 bytes of 288001 total bytes
Uploaded 192000 bytes of 288001 total bytes
Uploaded 256000 bytes of 288001 total bytes
Uploaded 288001 bytes of 288001 total bytes
-> Ok

I created a testfile with filesize 256001

Uploaded 64000 bytes of 256001 total bytes
Uploaded 128000 bytes of 256001 total bytes
Uploaded 192000 bytes of 256001 total bytes
Uploaded 256000 bytes of 256001 total bytes
-> last one missing

Slice: 96000
Uploaded 96000 bytes of 256001 total bytes
Uploaded 192000 bytes of 256001 total bytes
Uploaded 256001 bytes of 256001 total bytes
-> Ok

` CreateUploadSessionPostRequestBody uploadSessionRequest = new CreateUploadSessionPostRequestBody();
DriveItemUploadableProperties properties = new DriveItemUploadableProperties();
properties.getAdditionalData().put("@microsoft.graph.conflictBehavior", "replace");
uploadSessionRequest.setItem(properties);

       UploadSession uploadSession = graphClient
               .drives()
               .byDriveId(driveId)
               .items()
               .byDriveItemId(pfad)
               .createUploadSession()
               .post(uploadSessionRequest);

       // Create the upload task
       int maxSliceSize = 320 * 100;
       LargeFileUploadTask<DriveItem> largeFileUploadTask = new LargeFileUploadTask<>(
               graphClient.getRequestAdapter(),
               uploadSession,
               fileStream,
               streamSize,
               maxSliceSize,
               DriveItem::createFromDiscriminatorValue);

       int maxAttempts = 5;

       // Create a callback used by the upload provider
       IProgressCallback callback = (current, max) -> System.out.println(
               String.format("Uploaded %d bytes of %d total bytes", current, max));

        // Do the upload

       UploadResult<DriveItem> uploadResult = largeFileUploadTask.upload(maxAttempts, callback);
       if (uploadResult.isUploadSuccessful()) {
           logger.info("Upload complete");
           logger.info("Item ID: {}",uploadResult.itemResponse.getId());
       } else {
           logger.info("Upload failed");
       }`
Expected behavior

Upload complete file

How to reproduce

Create a file with filesize = x * maxSliceSize +1

SDK Version

6.62.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```

Error Message:
Caused by: java.util.concurrent.CancellationException: The upload task was retried the maximum number of times without success and has been cancelled.
at com.microsoft.graph.core.tasks.LargeFileUploadTask.upload(LargeFileUploadTask.java:149)

</details>


### Configuration

 Linux
Java 8
x64

### Other information

_No response_

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne bei com.microsoft.graph.core.tasks.LargeFileUploadTask.upload, identifiziert in LargeFileUploadTask.java:149, und reproduziere den Fehler mit einer Datei der Größe x * maxSliceSize + 1. Verfolge, wie der abschließende Ein-Byte-Slice verarbeitet wird, und überprüfe, dass der Upload ohne Abbruch erfolgreich abgeschlossen wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
api
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.